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

Unified Diff: go/src/infra/libs/logging/gologger/gologger.go

Issue 1153883002: go: infra/libs/* now live in luci-go. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: move the rest too 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
Index: go/src/infra/libs/logging/gologger/gologger.go
diff --git a/go/src/infra/libs/logging/gologger/gologger.go b/go/src/infra/libs/logging/gologger/gologger.go
deleted file mode 100644
index 82ef9c13e3bf859aec259d577c1dec3df0040b6e..0000000000000000000000000000000000000000
--- a/go/src/infra/libs/logging/gologger/gologger.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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.
-
-package gologger
-
-import (
- "golang.org/x/net/context"
- "os"
-
- gol "github.com/op/go-logging"
-
- "infra/libs/logging"
-)
-
-const fmt string = "%{color}" +
- "[P%{pid} %{time:15:04:05.000} %{shortfile} %{level:.4s} %{id:03x}]" +
- "%{color:reset} %{message}"
-
-type loggerImpl struct {
- l *gol.Logger
-}
-
-func (l *loggerImpl) Infof(format string, args ...interface{}) { l.l.Info(format, args...) }
-func (l *loggerImpl) Warningf(format string, args ...interface{}) { l.l.Warning(format, args...) }
-func (l *loggerImpl) Errorf(format string, args ...interface{}) { l.l.Error(format, args...) }
-
-// UseFile adds a go-logging logger to the context which writes to the provided
-// file. Caller is still responsible for closing the file when no longer needed.
-func UseFile(c context.Context, f *os.File) context.Context {
- backend := gol.NewLogBackend(f, "", 0)
- formatted := gol.NewBackendFormatter(backend, gol.MustStringFormatter(fmt))
- gol.SetBackend(formatted)
- log := &loggerImpl{gol.MustGetLogger("")}
- log.l.ExtraCalldepth = 1 // one layer of wrapping in loggerImpl struct above
- return logging.Set(c, func(context.Context) logging.Logger { return log })
-}
-
-// Use adds a go-logging logger to the context which writes to os.Stdout.
-func Use(c context.Context) context.Context {
- return UseFile(c, os.Stdout)
-}
-
-// Get returns default go-logging based logger.
-func Get() logging.Logger {
- return logging.Get(Use(context.Background()))
-}
« no previous file with comments | « go/src/infra/libs/logging/gaelogger/gaelogger.infra_testing ('k') | go/src/infra/libs/logging/gologger/gologger.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698