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

https://github.com/containerscrew/devstdout

Simple slog wrapper pkg
https://github.com/containerscrew/devstdout

golang golang-package logger logging logging-library slog

Last synced: 21 days ago
JSON representation

Simple slog wrapper pkg

Awesome Lists containing this project

README

          


logo

devstdout


Simple slog wrapper pkg


Built with ❤ in Golang


Go report card
GitHub code size in bytes
GitHub go.mod Go version
LICENSE
LICENSE

**Table of Contents** *generated with [mtoc](https://github.com/containerscrew/mtoc)*
- [devstdout](#devstdout)
- [Examples](#examples)
- [Full code examples](#full-code-examples)
- [Pretty output](#pretty-output)
- [Json output](#json-output)
- [TO DO](#to-do)
- [License](#license)

# devstdout

Simple slog wrapper pkg for my Golang projects.

# Examples

```go
package main

import (
devstdout "github.com/containerscrew/devstdout/pkg"
)

func main() {
log := devstdout.NewLogger(
devstdout.OptionsLogger{Level: "debug", AddSource: false, LoggerType: "pretty"},
)

log.Debug(
"testing message",
devstdout.Argument("hello", "world"),
)

log.Info(
"testing message",
devstdout.Argument("bob", "marley"),
)

log.Warning("warning message!")

log.Success(
"Success Message",
devstdout.Argument("alice", "bob"),
)

log.Error("error in your app!", devstdout.Argument("error", "your_error_is_here"))

log.ErrorWithExit("fatal error, app must stop!", devstdout.Argument("error", "your_error_is_here"))
}
```

## Full code examples

* [**json**](./examples/json/json.go)
* [**pretty**](./examples/pretty/pretty.go)
* [**console**](./examples/console/console.go)

## Pretty output
![example](./img/example.png)

## Json output
![example2](./img/example2.png)

# TO DO

* Add tests
* Code refactor is certainly needed!
* AddSource option in logger is too much verbose

# License

[LICENSE](./LICENSE)