logger/README.md

75 lines
1.5 KiB
Markdown
Raw Normal View History

# Kris Nóva Logger
2018-11-27 23:47:56 +01:00
## History
- [2017] Originally ported from it's [original location](https://github.com/kubicorn/kubicorn/tree/master/pkg/logger) in the Kubicorn code base.
- [2021] Refactored to support custom `io.Writer`'s
2018-11-27 23:47:56 +01:00
2018-11-27 23:53:14 +01:00
<center><img src="/screenshot.png"></center>
2018-11-27 23:51:36 +01:00
## Install
```bash
go get github.com/kris-nova/logger
```
2018-11-27 23:51:36 +01:00
## Basic Usage
```go
2018-11-27 23:51:36 +01:00
package main
import (
"github.com/kris-nova/logger"
"os"
)
func main() {
// Options
logger.Writer = os.Stdout // This is not needed
logger.BitwiseLevel = logger.LogCritical | logger.LogWarning // Customize your levels
logger.BitwiseLevel = logger.LogEverything // Turn everything on
logger.BitwiseLevel = logger.LogAlways // Only log Always()
logger.BitwiseLevel = logger.LogEverything // Turn everything back on
//
// Log lines
logger.Debug("Check this out %d", 123)
logger.Info("Cool!")
logger.Success("Hooray!")
logger.Always("Hello!")
logger.Critical("Oh No!")
logger.Warning("Beware...")
logger.Deprecated("Don't do this!")
//
2018-11-27 23:51:36 +01:00
}
```
## Rainbow logs
2018-11-27 23:47:56 +01:00
```go
2018-11-27 23:47:56 +01:00
package main
import (
"github.com/kris-nova/logger"
lol "github.com/kris-nova/lolgopher"
2018-11-27 23:47:56 +01:00
)
func main(){
//
logger.Writer = lol.NewLolWriter() // Sometimes this will work better
logger.Writer = lol.NewTruecolorLolWriter() // Comment one of these out
//
logger.BitwiseLevel = logger.LogEverything
logger.Always("Rainbow logging")
logger.Always("Rainbow logging")
logger.Always("Rainbow logging")
logger.Always("Rainbow logging")
2018-11-27 23:47:56 +01:00
}
```