| Index: chrome/common/extensions/docs/server2/custom_logger.py
|
| diff --git a/chrome/common/extensions/docs/server2/custom_logger.py b/chrome/common/extensions/docs/server2/custom_logger.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..974da6faa4d12cc17dabb23a887384fdcae989f5
|
| --- /dev/null
|
| +++ b/chrome/common/extensions/docs/server2/custom_logger.py
|
| @@ -0,0 +1,26 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import logging
|
| +
|
| +from appengine_wrappers import logservice
|
| +
|
| +
|
| +class CustomLogger(object):
|
| + '''Wraps logging methods to include a prefix and flush immediately.
|
| + The flushing is important because logging is often done from jobs
|
| + which may time out, thus losing unflushed logs.
|
| + '''
|
| + def __init__(self, prefix):
|
| + self._prefix = prefix
|
| +
|
| + def info(self, msg, *args): self._log(logging.info, msg, args)
|
| + def warning(self, msg, *args): self._log(logging.warning, msg, args)
|
| + def error(self, msg, *args): self._log(logging.error, msg, args)
|
| +
|
| + def _log(self, logfn, msg, args):
|
| + try:
|
| + logfn('%s: %s' % (self._prefix, msg), *args)
|
| + finally:
|
| + logservice.flush()
|
|
|