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

Side by Side Diff: go/src/infra/libs/logging/logging.go

Issue 1149313002: go: Replace Logrus with go-logging. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: typo Created 5 years, 7 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
« no previous file with comments | « go/src/infra/libs/logging/go-logging.go ('k') | go/src/infra/libs/logging/logrus.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* 5 /*
6 Package logging defines Logger interface with implementations on top of Logrus 6 Package logging defines Logger interface with implementations on top of
7 library and Appengine context. Unfortunately standard library doesn't define 7 go-logging library and Appengine context. Unfortunately standard library doesn't
8 any Logger interface (only struct). And even worse: GAE logger is exposing 8 define any Logger interface (only struct). And even worse: GAE logger is
9 different set of methods. Some additional layer is needed to unify the logging. 9 exposing different set of methods. Some additional layer is needed to unify
10 the logging.
10 11
11 Package logging is intended to be used from packages that support both local and 12 Package logging is intended to be used from packages that support both local and
12 GAE environments. Such packages should not use global logger but must accept 13 GAE environments. Such packages should not use global logger but must accept
13 instances of Logger interface as parameters in functions. Then callers can pass 14 instances of Logger interface as parameters in functions. Then callers can pass
14 logrus.Logger or appengine.Context depending on where the code is running. 15 DefaultLogger or appengine.Context depending on where the code is running.
15 16
16 Libraries under infra/libs/* MUST use infra/libs/logger instead of directly 17 Libraries under infra/libs/* MUST use infra/libs/logger instead of directly
17 calling to Logrus library. 18 calling to a logging library.
18 */ 19 */
19 package logging 20 package logging
20 21
21 // Logger is interface implemented by both logrus.Logger and appengine.Context, 22 // Logger is interface implemented by both DefaultLogger and appengine.Context,
22 // and thus it can be used in libraries that expect to be called from both kinds 23 // and thus it can be used in libraries that expect to be called from both kinds
23 // of environments. 24 // of environments.
24 type Logger interface { 25 type Logger interface {
25 // Infof formats its arguments according to the format, analogous to fmt .Printf, 26 // Infof formats its arguments according to the format, analogous to fmt .Printf,
26 // and records the text as a log message at Info level. 27 // and records the text as a log message at Info level.
27 Infof(format string, args ...interface{}) 28 Infof(format string, args ...interface{})
28 29
29 // Warningf is like Infof, but logs at Warning level. 30 // Warningf is like Infof, but logs at Warning level.
30 Warningf(format string, args ...interface{}) 31 Warningf(format string, args ...interface{})
31 32
32 // Errorf is like Infof, but logs at Error level. 33 // Errorf is like Infof, but logs at Error level.
33 Errorf(format string, args ...interface{}) 34 Errorf(format string, args ...interface{})
34 } 35 }
35 36
36 // DefaultLogger is logger to use if no specialized logger is provided. In local 37 // DefaultLogger is logger to use if no specialized logger is provided. In local
37 // environment it is Logrus logger, on GAE it is null logger (since GAE logger 38 // environment it is backed by go-logging, on GAE it is null logger (since GAE
38 // requires active appengine.Context). 39 // logger requires active appengine.Context).
39 var DefaultLogger Logger 40 var DefaultLogger Logger
40
41 // IsTerminal is true if current process is attached to an interactive terminal.
42 var IsTerminal bool
43
44 // Infof formats its arguments according to the format, analogous to fmt.Printf,
45 // and records the text as a log message at Info level.
46 func Infof(format string, args ...interface{}) { DefaultLogger.Infof(format, arg s...) }
47
48 // Warningf is like Infof, but logs at Warning level.
49 func Warningf(format string, args ...interface{}) { DefaultLogger.Warningf(forma t, args...) }
50
51 // Errorf is like Infof, but logs at Error level.
52 func Errorf(format string, args ...interface{}) { DefaultLogger.Errorf(format, a rgs...) }
OLDNEW
« no previous file with comments | « go/src/infra/libs/logging/go-logging.go ('k') | go/src/infra/libs/logging/logrus.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698