mirror of
https://github.com/status-im/status-go.git
synced 2025-02-22 19:58:29 +00:00
67 lines
2.1 KiB
Markdown
67 lines
2.1 KiB
Markdown
|
# go-log
|
||
|
|
||
|
[](http://ipn.io)
|
||
|
[](http://ipfs.io/)
|
||
|
[](http://webchat.freenode.net/?channels=%23ipfs)
|
||
|
[](https://github.com/RichardLitt/standard-readme)
|
||
|
[](https://godoc.org/github.com/ipfs/go-log)
|
||
|
[](https://travis-ci.org/ipfs/go-log)
|
||
|
|
||
|
<!---[](https://coveralls.io/github/ipfs/go-log?branch=master)--->
|
||
|
|
||
|
|
||
|
> The logging library used by go-ipfs
|
||
|
|
||
|
go-log wraps [zap](https://github.com/uber-go/zap) to provide a logging facade. go-log manages logging
|
||
|
instances and allows for their levels to be controlled individually.
|
||
|
|
||
|
## Install
|
||
|
|
||
|
```sh
|
||
|
go get github.com/ipfs/go-log
|
||
|
```
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
Once the package is imported under the name `logging`, an instance of `EventLogger` can be created like so:
|
||
|
|
||
|
```go
|
||
|
var log = logging.Logger("subsystem name")
|
||
|
```
|
||
|
|
||
|
It can then be used to emit log messages in plain printf-style messages at seven standard levels:
|
||
|
|
||
|
Levels may be set for all loggers:
|
||
|
|
||
|
```go
|
||
|
lvl, err := logging.LevelFromString("error")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
logging.SetAllLoggers(lvl)
|
||
|
```
|
||
|
|
||
|
or individually:
|
||
|
|
||
|
```go
|
||
|
lvl, err := logging.LevelFromString("error")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
logging.SetLogLevel("foo", "info")
|
||
|
```
|
||
|
|
||
|
## Contribute
|
||
|
|
||
|
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/go-log/issues)!
|
||
|
|
||
|
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
|
||
|
|
||
|
### Want to hack on IPFS?
|
||
|
|
||
|
[](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
|
||
|
|
||
|
## License
|
||
|
|
||
|
MIT
|