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

Unified Diff: go/src/infra/libs/logging/go-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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/libs/logging/appengine.go ('k') | go/src/infra/libs/logging/logging.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/libs/logging/go-logging.go
diff --git a/go/src/infra/libs/logging/go-logging.go b/go/src/infra/libs/logging/go-logging.go
new file mode 100644
index 0000000000000000000000000000000000000000..d99d50e400e3c3a90de7fe98587d539a6a480cb8
--- /dev/null
+++ b/go/src/infra/libs/logging/go-logging.go
@@ -0,0 +1,33 @@
+// Copyright 2015 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.
+
+// +build !appengine
+
+package logging
+
+import (
+ "os"
+
+ "github.com/op/go-logging"
+)
+
+const fmt string = "%{color}[P%{pid} %{time:15:04:05.000} %{shortfile} %{level:.4s} %{id:03x}]%{color:reset} %{message}"
+
+type logger struct {
+ l *logging.Logger
+}
+
+func (l *logger) Infof(format string, args ...interface{}) { l.l.Info(format, args...) }
+func (l *logger) Warningf(format string, args ...interface{}) { l.l.Warning(format, args...) }
+func (l *logger) Errorf(format string, args ...interface{}) { l.l.Error(format, args...) }
+
+func init() {
+ backend := logging.NewLogBackend(os.Stdout, "", 0)
+ formatted := logging.NewBackendFormatter(backend, logging.MustStringFormatter(fmt))
+ logging.SetBackend(formatted)
+
+ log := &logger{logging.MustGetLogger("")}
+ log.l.ExtraCalldepth = 1 // one layer of wrapping in logger struct above
+ DefaultLogger = log
+}
« no previous file with comments | « go/src/infra/libs/logging/appengine.go ('k') | go/src/infra/libs/logging/logging.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698