https://github.com/robertgzr/rlog
yet another logging library. (not really - only if you must)
https://github.com/robertgzr/rlog
env logging
Last synced: over 1 year ago
JSON representation
yet another logging library. (not really - only if you must)
- Host: GitHub
- URL: https://github.com/robertgzr/rlog
- Owner: robertgzr
- Created: 2018-02-12T01:17:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-17T04:45:20.000Z (about 8 years ago)
- Last Synced: 2025-01-28T01:48:10.236Z (over 1 year ago)
- Topics: env, logging
- Language: Go
- Homepage:
- Size: 260 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
rlog
====
_rust log or robert's log if you like ;)_
Mostly for my own projects, with inspiration taken from https://crates.io/crates/env_logger.
This package implements [`github.com/apex/log.Handler`](https://github.com/apex/log/blob/master/logger.go#L54).
It also offers a subset of [`apex/log.Interface`](https://github.com/apex/log/blob/master/interface.go#L4) that can be used directly.
The environment variable `GO_LOG` can be used to set the log level. Like `env_logger` we support tuning it on a package
basis, e.g. `GO_LOG=warn,sub=debug` would only log warn/error/fatal messages with exception of in the `sub` package,
where all logs get through.

## Usage
Really simple, just import the package and use it:
```
package main
import "github.com/robertgzr/rlog"
func main() {
rlog.Info("hello world!")
}
```
### To integrate with apex/log:
```
package main
import (
"github.com/apex/log"
"github.com/robertgzr/rlog"
)
func main() {
log.SetHandler(rlog.Default)
log.SetLevel(log.DebugLevel) // this overwrites the GO_LOG env
log.Debugf("%s is a string", "a string")
}
```
## Examples
Run `GO_LOG=warn,subpkg=debug go run _example/main.go`