From ba2ba315d08c9627cb2ecc385a25dd55d7e66f90 Mon Sep 17 00:00:00 2001 From: Martin Riedl Date: Tue, 4 Mar 2025 20:56:50 +0100 Subject: [PATCH] docs: enhanced simple example --- README.md | 2 ++ cmd/simple/main.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae24311..93d896e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ func main(){ } ``` +Check out this [simple example file](cmd/simple/main.go) for the basic usage. + ## Multiple Log Instance Create a new log instance (instead of using the `Default`). diff --git a/cmd/simple/main.go b/cmd/simple/main.go index 2b2b224..ced0b54 100644 --- a/cmd/simple/main.go +++ b/cmd/simple/main.go @@ -1,15 +1,24 @@ package main import ( - "git.martin-riedl.de/golang/log" "runtime" + + "git.martin-riedl.de/golang/log" ) func main() { someMethod() + anotherMethod() } func someMethod() { 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") }