README.md 2.09 KB
Newer Older
Richard Littauer's avatar
Richard Littauer committed
1 2 3 4 5 6 7
# go-log

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![GoDoc](https://godoc.org/github.com/ipfs/go-log?status.svg)](https://godoc.org/github.com/ipfs/go-log)
8
[![CircleCI](https://img.shields.io/circleci/build/github/ipfs/go-log?style=flat-square)](https://circleci.com/gh/ipfs/go-log)
Richard Littauer's avatar
Richard Littauer committed
9

10 11 12
<!---[![Coverage Status](https://coveralls.io/repos/github/ipfs/go-log/badge.svg?branch=master)](https://coveralls.io/github/ipfs/go-log?branch=master)--->


Jesse Weinstein's avatar
Jesse Weinstein committed
13 14
> The logging library used by go-ipfs

15 16
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.
Richard Littauer's avatar
Richard Littauer committed
17 18 19 20 21 22 23 24 25

## Install

```sh
go get github.com/ipfs/go-log
```

## Usage

Jim Pick's avatar
Jim Pick committed
26
Once the package is imported under the name `logging`, an instance of `EventLogger` can be created like so:
Jesse Weinstein's avatar
Jesse Weinstein committed
27

28
```go
Jesse Weinstein's avatar
Jesse Weinstein committed
29 30
var log = logging.Logger("subsystem name")
```
31

32
It can then be used to emit log messages in plain printf-style messages at seven standard levels:
Richard Littauer's avatar
Richard Littauer committed
33

34
Levels may be set for all loggers:
35 36

```go
37 38 39 40 41
lvl, err := logging.LevelFromString("error")
  if err != nil {
    panic(err)
  }
logging.SetAllLoggers(lvl)
42 43
```

44
or individually:
45

46 47 48 49 50 51 52
```go
lvl, err := logging.LevelFromString("error")
  if err != nil {
    panic(err)
  }
logging.SetLogLevel("foo", "info")
```
53

Richard Littauer's avatar
Richard Littauer committed
54 55 56 57 58 59 60 61
## 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?

Bryan Stenson's avatar
Bryan Stenson committed
62
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
Richard Littauer's avatar
Richard Littauer committed
63 64 65

## License

Jesse Weinstein's avatar
Jesse Weinstein committed
66
MIT