...
1# glog
2
3[](https://pkg.go.dev/github.com/golang/glog)
4
5Leveled execution logs for Go.
6
7This is an efficient pure Go implementation of leveled logs in the
8manner of the open source C++ package [_glog_](https://github.com/google/glog).
9
10By binding methods to booleans it is possible to use the log package without paying the expense of evaluating the arguments to the log. Through the `-vmodule` flag, the package also provides fine-grained
11control over logging at the file level.
12
13The comment from `glog.go` introduces the ideas:
14
15Package _glog_ implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. It provides the functions Info, Warning, Error, Fatal, plus formatting variants such as Infof. It also provides V-style loggingcontrolled by the `-v` and `-vmodule=file=2` flags.
16
17Basic examples:
18
19```go
20glog.Info("Prepare to repel boarders")
21
22glog.Fatalf("Initialization failed: %s", err)
23```
24
25See the documentation for the V function for an explanation of these examples:
26
27```go
28if glog.V(2) {
29 glog.Info("Starting transaction...")
30}
31glog.V(2).Infoln("Processed", nItems, "elements")
32```
33
34The repository contains an open source version of the log package used inside Google. The master copy of the source lives inside Google, not here. The code in this repo is for export only and is not itself under development. Feature requests will be ignored.
35
36Send bug reports to golang-nuts@googlegroups.com.
View as plain text