OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 backend := logging.NewLogBackend(os.Stdout, "", 0) |
| 27 formatted := logging.NewBackendFormatter(backend, logging.MustStringForm
atter(fmt)) |
| 28 logging.SetBackend(formatted) |
| 29 |
| 30 log := &logger{logging.MustGetLogger("")} |
| 31 log.l.ExtraCalldepth = 1 // one layer of wrapping in logger struct above |
| 32 DefaultLogger = log |
| 33 } |
OLD | NEW |