OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 // +build !appengine |
| 6 |
| 7 package logging |
| 8 |
| 9 import ( |
| 10 "os" |
| 11 |
| 12 "github.com/op/go-logging" |
| 13 ) |
| 14 |
| 15 const fmt string = "%{color}[P%{pid} %{time:15:04:05.000} %{shortfile} %{level:.
4s} %{id:03x}]%{color:reset} %{message}" |
| 16 |
| 17 type logger struct { |
| 18 l *logging.Logger |
| 19 } |
| 20 |
| 21 func (l *logger) Infof(format string, args ...interface{}) { l.l.Info(format,
args...) } |
| 22 func (l *logger) Warningf(format string, args ...interface{}) { l.l.Warning(form
at, args...) } |
| 23 func (l *logger) Errorf(format string, args ...interface{}) { l.l.Error(format
, args...) } |
| 24 |
| 25 func init() { |
| 26 // TODO(vadimsh): Reimplement when moved to luci-go. luci-go has this fu
nction |
| 27 // already. |
| 28 IsTerminal = true |
| 29 |
| 30 backend := logging.NewLogBackend(os.Stdout, "", 0) |
| 31 formatted := logging.NewBackendFormatter(backend, logging.MustStringForm
atter(fmt)) |
| 32 logging.SetBackend(formatted) |
| 33 |
| 34 l := logging.MustGetLogger("") |
| 35 l.ExtraCalldepth = 2 |
| 36 DefaultLogger = &logger{l} |
| 37 } |
OLD | NEW |