• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README.mdH A D28-Mar-20162.3 KiB

logger.goH A D28-Mar-20165.9 KiB

multisink.goH A D28-Mar-20161 KiB

severity.goH A D28-Mar-20162.7 KiB

syslogsink.goH A D28-Mar-20161.3 KiB

terminal-null.goH A D28-Mar-2016140

terminal.goH A D28-Mar-2016265

writersink.goH A D28-Mar-20161.5 KiB

xlog.goH A D28-Mar-20164.5 KiB

README.md

1# xlog [![GoDoc](https://godoc.org/github.com/hlandau/xlog?status.svg)](https://godoc.org/github.com/hlandau/xlog)
2
3Yet another logging package for Go.
4
5The main thing about this package is that it's good for usage in libraries and
6doesn't involve itself with policy. Essentially, if, as a library, you want to
7log something, you write this:
8
9```go
10var log, Log = xlog.NewQuiet("my.logger.name")
11
12func Foo() {
13  log.Debugf("Bar")
14}
15```
16
17The `log` variable is what you use to log, and the `Log` variable is exported
18from the package and provides methods for controlling the log site. (These are
19actually two interfaces to the same object which enforce this pattern.)
20
21The idea is that consuming code can call somepkg.Log to control where it logs
22to, at what verbosity, etc.
23
24You should instantiate with `NewQuiet` if you are a library, as this suppresses
25most log messages by default. Loggers created with `New` don't suppress
26any log messages by default.
27
28xlog uses a traditional Print/Printf interface. It also has the following
29conveniences:
30
31  - Methods ending in `e`, such as `Debuge`, take an error as their first
32    argument and are no-ops if it is nil.
33
34  - `Fatal` and `Panic` call os.Exit(1) and Panic, respectively.
35    The `e` variants of these are no-ops if the error is nil, providing
36    a simple assertion mechanism.
37
38xlog uses syslog severities (Emergency, Alert, Critical, Error, Warning,
39Notice, Info, Debug) and also provides a Trace severity which is even less
40severe than Debug. You should generally not emit Alert or Emergency severities
41from your code, as these are of system-level significance.
42
43You can visit all registered log sites in order to configure loggers
44programmatically.
45
46Loggers should be named via a dot-separated hierarchy with names in lowercase.
47If you have a repository called `foo` and a subpackage `baz`, naming the logger
48for that subpackage `foo.baz` might be reasonable.
49
50Loggers are arranged in a hierarchy terminating in the root logger, which is
51configured to log to stderr by default. You can create a logger under another
52logger using `NewUnder`.
53
54## Licence
55
56    © 2014—2016 Hugo Landau <hlandau@devever.net>  MIT License
57
58[Licenced under the licence with SHA256 hash
59`fd80a26fbb3f644af1fa994134446702932968519797227e07a1368dea80f0bc`, a copy of
60which can be found
61here.](https://raw.githubusercontent.com/hlandau/acme/master/_doc/COPYING.MIT)
62