https://github.com/levicook/smaug
Boring leveled logging in Go. Because logging should be boring.
https://github.com/levicook/smaug
Last synced: 15 days ago
JSON representation
Boring leveled logging in Go. Because logging should be boring.
- Host: GitHub
- URL: https://github.com/levicook/smaug
- Owner: levicook
- License: mit
- Created: 2014-05-25T02:39:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-25T02:44:01.000Z (about 12 years ago)
- Last Synced: 2025-10-20T04:53:39.710Z (10 months ago)
- Language: Go
- Homepage:
- Size: 121 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
smaug
=====
Package smaug implements a simple leveled logging package.
There are four logging levels: `DEBUG`, `INFO`, `WARN` and `ERROR`.
And four corresponding loggers: `Debug`, `Info`, `Warn` and `Error`.
Each logger provides four logging methods: `Dump`, `Print`, `Printf` and
`Println`.
`Dump` is a pretty printer.
`Print`, `Printf` and `Println` wrap the equivalent functions in the
standard library log package.
```go
// set our log level to INFO
smaug.Level = smaug.INFO
// logging through Debug will not create ouptut
smaug.Debug.Print("you won't see me")
// logging through Info, Warn and will create ouptut
smaug.Info.Print("you will see me")
smaug.Warn.Print("you will see me")
smaug.Error.Print("you will see me")
```
Package smaug also contains convenience methods for single error
handling, where you're okay with panicing or exiting your process.
```go
// this will call log.Fatal:
smaug.FatalIf(func () error {
return errors.New("oh no!")
})
// this will call log.Panic:
smaug.PanicIf(func () error {
return errors.New("oh no!")
})
```
Overall, no big shakes. Just a lighweight wrapper around other packages.