Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/common/extensions/docs/server2/custom_logger.py

Issue 575613003: Docserver: Gitiles auth and cron refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6
7 from appengine_wrappers import logservice
8
9
10 class CustomLogger(object):
11 '''Wraps logging methods to include a prefix and flush immediately.
12 The flushing is important because logging is often done from jobs
13 which may time out, thus losing unflushed logs.
14 '''
15 def __init__(self, prefix):
16 self._prefix = prefix
17
18 def info(self, msg, *args): self._log(logging.info, msg, args)
19 def warning(self, msg, *args): self._log(logging.warning, msg, args)
20 def error(self, msg, *args): self._log(logging.error, msg, args)
21
22 def _log(self, logfn, msg, args):
23 try:
24 logfn('%s: %s' % (self._prefix, msg), *args)
25 finally:
26 logservice.flush()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron_servlet.py ('k') | chrome/common/extensions/docs/server2/data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698