1- # Structured leveled log interface
1+ [ ![ Build status ] [ buildimage ]] [ build ] [ ![ Coverage ] [ codecovimage ]] [ codecov ] [ ![ GoReportCard ] [ cardimage ]] [ card ] [ ![ API documentation ] [ docsimage ]] [ docs ]
22
3- Package ` log ` decouples the logger backend from your application. It defines
3+ # Structured log interface
4+
5+ Package ` log ` provides the separation of the logging interface from its
6+ implementation and decouples the logger backend from your application. It defines
47a simple, lightweight and comprehensive ` Logger ` and ` Factory ` interfaces which
58can be used through your applications without any knowledge of the particular
69implemeting backend and can be configured at the application wiring point to
710bind a particular backend, such as Go's standard logger, ` apex/log ` , ` logrus ` ,
811with ease.
912
10- To complement the facade, the package ` code. teris.io/util /log/std` provides an
13+ To complement the facade, the package ` github.com/ teris-io /log/std` provides an
1114implementation using the standard Go logger. The default log formatter for
1215this implementation uses colour coding for log levels and logs the date
1316leaving out the month and the year on the timestamp. However, the formatter
1417is fully configurable.
1518
16- Similarly, the package ` code. teris.io/util /log/apex` provides and implementation
19+ Similarly, the package ` github.com/ teris-io /log/apex` provides and implementation
1720using the ` apex/log ` logger backend.
1821
1922
@@ -26,7 +29,7 @@ type Logger interface {
2629 Level (lvl LogLevel ) Logger
2730 Field (k string , v interface {}) Logger
2831 Fields (data map [string ]interface {}) Logger
29- WithError (err error ) Logger
32+ Error (err error ) Logger
3033 Log (msg string ) Tracer
3134 Logf (format string , v ...interface {}) Tracer
3235}
@@ -52,19 +55,19 @@ The log can be used both statically by binding a particular logger factory:
5255
5356``` go
5457func init () {
55- std.Use (os.Stderr , log.Info , std.DefaultFmtFun )
58+ std.Use (os.Stderr , log.InfoLevel , std.DefaultFmtFun )
5659}
5760
5861// elsewhere
59- logger := log.Level (log.Info ).Field (" key" , " value" )
62+ logger := log.Level (log.InfoLevel ).Field (" key" , " value" )
6063logger.Log (" message" )
6164```
6265
6366and dynamically by always going via a factory:
6467
6568``` go
66- factory := std.NewFactory (os.Stderr , log.Info , std.DefaultFmtFun )
67- logger := factory.Level (log.Info ).Field (" key" , " value" )
69+ factory := std.NewFactory (os.Stderr , log.InfoLevel , std.DefaultFmtFun )
70+ logger := factory.Level (log.InfoLevel ).Field (" key" , " value" )
6871logger.Log (" message" )
6972```
7073
@@ -76,7 +79,7 @@ To simplify debugging with execution time tracing, the `Log` and `Logf` methods
7679return a tracer that can be used to measure and log the execution time:
7780
7881``` go
79- logger := log.Level (log.Debug ).Field (" key" , " value" )
82+ logger := log.Level (log.DebugLevel ).Field (" key" , " value" )
8083
8184defer logger.Log (" start" ).Trace ()
8285// code to trace the execution time of
@@ -88,25 +91,19 @@ the selected `Debug` level (her for the default formatter of the `std` logger):
8891 08 16:31:42.023798 DBG start {key: value}
8992 08 16:31:45.127619 DBG traced {duration: 3.103725832}, {key: value}
9093
91- # License and copyright
94+ ### License and copyright
95+
96+ Copyright (c) 2017. Oleg Sklyar and teris.io. MIT license applies. All rights reserved.
9297
93- Copyright (c) 2017 Oleg Sklyar & teris.io
9498
95- MIT License
99+ [ build ] : https://travis-ci.org/teris-io/log
100+ [ buildimage ] : https://travis-ci.org/teris-io/log.svg?branch=master
96101
97- Permission is hereby granted, free of charge, to any person obtaining a copy of this
98- software and associated documentation files (the "Software"), to deal in the Software
99- without restriction, including without limitation the rights to use, copy, modify,
100- merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
101- permit persons to whom the Software is furnished to do so, subject to the following
102- conditions:
102+ [ codecov ] : https://codecov.io/github/teris-io/log?branch=master
103+ [ codecovimage ] : https://codecov.io/github/teris-io/log/coverage.svg?branch=master
103104
104- The above copyright notice and this permission notice shall be included in all copies
105- or substantial portions of the Software.
105+ [ card ] : http://goreportcard.com/report/teris-io/log
106+ [ cardimage ] : https://goreportcard.com/badge/github.com/teris-io/log
106107
107- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
108- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
109- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
110- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
111- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
112- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
108+ [ docs ] : https://godoc.org/github.com/teris-io/log
109+ [ docsimage ] : http://img.shields.io/badge/godoc-reference-blue.svg?style=flat
0 commit comments