1# gologme/log #
2
3[![GoDoc](https://godoc.org/github.com/gologme/log?status.png)](https://godoc.org/github.com/gologme/log)
4
5This package is a drop in replacement for the built-in Go log package. All the
6functionality of the built-in package still exists and is unchanged. In addition,
7this package contains a series of small enhancements and additions. Namely, it
8adds four logging levels. These logging levels are:
9
10- Info
11- Warn
12- Error
13- Debug
14- Trace
15
16In addition to these four defined logging levels, users can also define their
17own arbitrary logging levels.
18
19Unlike other loggers, these logging levels are not enabled in a chain. Meaning,
20once a level is enabled, say Warn, all levels above it are not also enabled.
21This package is implemented in such a way that users can individually turn on
22and turn off the various new logging levels. If existing code uses the build-in
23log package, no change is needed to use this package.
24
25Another feature that was added, based on comments seen on the various golang
26boards, is the ability to set the calldepth.
27
28
29## Version ##
301.2.0
31
32
33## Installation ##
34
35This package can be installed with the go get command:
36```
37go get github.com/gologme/log
38go install github.com/gologme/log
39```
40
41## Example ##
42
43Just like the built-in package, code can still do simple logging just like:
44```
45log.Println("some interesting logging message")
46```
47
48In addition to this, users can enable info, warn, error, debug, or trace logging like:
49```
50log.EnableLevel("info")
51log.EnableLevel("warn")
52log.EnableLevel("error")
53log.EnableLevel("debug")
54log.EnableLevel("trace")
55```
56
57Once these levels are enabled, calls to the info, warn, error, debug, or trace loggers
58will print out just like they do for the Print and Fatal built-in loggers. The
59functions / methods definitions that are defined for each level, match exactly
60the ones defined in the built-in package. The new functions/methods are called:
61```
62log.Info()
63log.Infof()
64log.Infoln()
65log.Warn()
66log.Warnf()
67log.Warnln()
68log.Error()
69log.Errorf()
70log.Errorln()
71log.Debug()
72log.Debugf()
73log.Debugln()
74log.Trace()
75log.Tracef()
76log.Traceln()
77```
78
79In addition to the defined levels, arbitrary levels can be enabled.  For example:
80```
81log.EnableLevel("tracedebug")
82```
83
84This level can then be used from an application as shown below. All three
85functions/methods are defined for this: log.Level(), log.Levelln(), log.Levelf().
86For each of these, the first argument is the level name.
87```
88log.Levelln("tracedebug", "some other neat logging message for this level")
89```
90
91The last thing that was enabled was the ability to define the calldepth. The
92built-in package from the Go authors had this hard coded to a value of 2. A small
93change was made to enable this to be set by the application using the log package.
94From the Go authors source code it seems like the normal possible values would
95be 1, 2, or 3.
96```
97log.SetCallDepth()
98```
99
100
101## License ##
102
103This is free software, licensed under the same BSD license that the original
104Go log package was licensed.
105
106
107## Copyright ##
108
109Copyright 2017 Bret Jordan, All rights reserved.
110