docs: enhanced simple example
This commit is contained in:
parent
a1c991bcbd
commit
ba2ba315d0
2 changed files with 13 additions and 2 deletions
|
@ -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`).
|
||||||
|
|
|
@ -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")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue