Skip to content

containerscrew/devstdout

Repository files navigation

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

devstdout

Simple slog wrapper pkg for my Golang projects.

Examples

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

Pretty output

example

Json output

example2

TO DO

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

License

LICENSE

About

Simple slog wrapper pkg

Topics