docs: enhanced simple example
All checks were successful
Build / Checks (push) Successful in 33s
Build / Code Coverage (push) Successful in 43s
Build / Build (push) Successful in 30s
Release / Semantic Release (push) Successful in 45s

This commit is contained in:
Martin Riedl 2025-03-04 20:56:50 +01:00
parent a1c991bcbd
commit ba2ba315d0
Signed by: martinr92
GPG key ID: FB68DA65516A804C
2 changed files with 13 additions and 2 deletions

View file

@ -12,6 +12,8 @@ func main(){
} }
``` ```
Check out this [simple example file](cmd/simple/main.go) for the basic usage.
## Multiple Log Instance ## Multiple Log Instance
Create a new log instance (instead of using the `Default`). Create a new log instance (instead of using the `Default`).

View file

@ -1,15 +1,24 @@
package main package main
import ( import (
"git.martin-riedl.de/golang/log"
"runtime" "runtime"
"git.martin-riedl.de/golang/log"
) )
func main() { func main() {
someMethod() someMethod()
anotherMethod()
} }
func someMethod() { func someMethod() {
log.Default.Info("Hello World") log.Default.Info("Hello World")
log.Default.With("os", runtime.GOOS).Info("environment detected") log.Default.With("os", runtime.GOOS).Warning("environment detected")
}
func anotherMethod() {
log.Default.WithMap(map[string]any{
"foo": "bar",
"bar": "baz",
}).Info("Second Hello World")
} }