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.
7 from environment
import IsAppEngine
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.
15 def __init__(self
, prefix
):
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
)
22 def _log(self
, logfn
, msg
, args
):
24 logfn('%s: %s' % (self
._prefix
, msg
), *args
)
29 from google
.appengine
.api
.logservice
import logservice