Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/qmsk/go-logging

Trivial logging package for Go libraries
https://github.com/qmsk/go-logging

Last synced: about 1 month ago
JSON representation

Trivial logging package for Go libraries

Awesome Lists containing this project

README

        

# Usage

The zero-valued `logging.Logging` struct functions as a no-op logger that does not output anything.

### `mypackage/logging.go`

```go
package mypackage

import (
"github.com/qmsk/go-logging"
)

var log logging.Logging

func SetLogging(l logging.Logging) {
log = l
}
```

### `cmd/mycmd/main.go`

```go
import (
"github.com/qmsk/go-logging"
"flag"
".../mypackage"
)

var LoggingOptions logging.Options

func init() {
LoggingOptions.InitFlags()
}

func main() {
flag.Parse()

mypackage.SetLogging(LoggingOptions.MakeLogging())

...
}
```