https://github.com/dolab/logger
Efficent and simple logger for golang with much more features.
https://github.com/dolab/logger
golang levels logger
Last synced: 5 months ago
JSON representation
Efficent and simple logger for golang with much more features.
- Host: GitHub
- URL: https://github.com/dolab/logger
- Owner: dolab
- License: mit
- Created: 2015-09-27T02:49:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-17T08:53:58.000Z (about 1 year ago)
- Last Synced: 2025-08-13T20:20:02.521Z (10 months ago)
- Topics: golang, levels, logger
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logger
[](https://circleci.com/gh/dolab/logger) [](https://godoc.org/github.com/dolab/logger) [](https://raw.githubusercontent.com/dolab/logger/master/LICENSE)
Efficient and simple logger for golang with more features supported.
- custom log levels
- custom log tags
- custom log colors (only worked for *NIX)
- custom log output and output format
- *structured log*
# Install
```go
go get -u github.com/dolab/logger
```
# Usage
```go
package main
import "github.com/dolab/logger"
func main() {
log, _ := logger.New("stdout")
log.SetLevel(logger.Ldebug)
// normal
log.Debug("Hello, logger!")
log.Infof("Hello, %s!", "logger")
// create new logger with tags based on log
taggedLog := log.New("X-REQUEST-ID")
taggedLog.Debug("Receive HTTP request")
taggedLog.Warnf("Send response with %d.", 200)
// or use struct log
textLog := log.NewTextLogger()
textLog.Str("key", "value").Err(err, true).Error("it's for demo")
}
```
# Output
- stdout = os.Stdout
- stderr = os.Stderr
- null | nil = os.DevNull
- path/to/file = os.OpenFile("path/to/file", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
# Level
- Ldebug = DEBUG
- Linfo = INFO
- Lwarn = WARN
- Lerror = ERROR
- Lfatal = FATAL
- Lpanic = PANIC
- Ltrace = Stack
# License
MIT
# Author
Spring MC