Skip to content

Commit 9d1cc30

Browse files
Merge branch 'master' of github.com:inconshreveable/log15
2 parents 9b11652 + f4ebf34 commit 9d1cc30

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

README.md

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![obligatory xkcd](http://imgs.xkcd.com/comics/standards.png)
22

3-
# log15
3+
# log15 [![godoc reference](https://godoc.org/gopkg.in/inconshreveable/log15.v2?status.png)](https://godoc.org/gopkg.in/inconshreveable/log15.v2)
44

55
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable. It is modeled after the standard library's io and net/http packages.
66

@@ -14,49 +14,45 @@ Package log15 provides an opinionated, simple toolkit for best-practice logging
1414
- Built-in support for logging to files, streams, syslog, and the network
1515
- Support for forking records to multiple handlers, buffering records for output, failing over from failed handler writes, + more
1616

17-
## Documentation
18-
19-
The package documentation is extensive and complete. Browse on godoc:
20-
21-
#### [log15 API Documentation](https://godoc.org/gopkg.in/inconshreveable/log15.v2)
22-
2317
## Versioning
2418
The API of the master branch of log15 should always be considered unstable. Using a stable version
2519
of the log15 package is supported by gopkg.in. Include your dependency like so:
2620

2721
import log "gopkg.in/inconshreveable/log15.v2"
2822

29-
You can also vendor log15 with a tool like Godep.
30-
3123
## Examples
3224

33-
// all loggers can have key/value context
34-
srvlog := log.New("module", "app/server")
25+
```go
26+
// all loggers can have key/value context
27+
srvlog := log.New("module", "app/server")
3528

36-
// all log messages can have key/value context
37-
srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
29+
// all log messages can have key/value context
30+
srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
3831

39-
// child loggers with inherited context
40-
connlog := srvlog.New("raddr", c.RemoteAddr())
41-
connlog.Info("connection open")
32+
// child loggers with inherited context
33+
connlog := srvlog.New("raddr", c.RemoteAddr())
34+
connlog.Info("connection open")
4235

43-
// lazy evaluation
44-
connlog.Debug("ping remote", "latency", log.Lazy(pingRemote))
36+
// lazy evaluation
37+
connlog.Debug("ping remote", "latency", log.Lazy(pingRemote))
4538

46-
// flexible configuration
47-
srvlog.SetHandler(log.MultiHandler(
48-
log.StreamHandler(os.Stderr, log.LogfmtFormat()),
49-
log.LvlFilterHandler(
50-
log.LvlError,
51-
log.Must.FileHandler("errors.json", log.JsonHandler())))
39+
// flexible configuration
40+
srvlog.SetHandler(log.MultiHandler(
41+
log.StreamHandler(os.Stderr, log.LogfmtFormat()),
42+
log.LvlFilterHandler(
43+
log.LvlError,
44+
log.Must.FileHandler("errors.json", log.JsonHandler())))
45+
```
5246

5347
## FAQ
5448

5549
### The varargs style is brittle and error prone! Can I have type saftey please?
5650
Yes. Use log.Ctx:
5751

58-
srvlog := log.New(log.Ctx{"module": "app/server"})
59-
srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate})
52+
```go
53+
srvlog := log.New(log.Ctx{"module": "app/server"})
54+
srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate})
55+
```
6056

6157
## License
6258
Apache

0 commit comments

Comments
 (0)