Compare commits

..

No commits in common. "v0.5.0" and "v0.4.1" have entirely different histories.

6 changed files with 4 additions and 28 deletions

View file

@ -12,8 +12,6 @@ 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`).

View file

@ -1,24 +1,15 @@
package main
import (
"runtime"
"git.martin-riedl.de/golang/log"
"runtime"
)
func main() {
someMethod()
anotherMethod()
}
func someMethod() {
log.Default.Info("Hello World")
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")
log.Default.With("os", runtime.GOOS).Info("environment detected")
}

View file

@ -49,13 +49,6 @@ func (entry *Entry) With(key string, value any) *Entry {
return entry
}
func (entry *Entry) WithMap(entries map[string]any) *Entry {
for key, value := range entries {
entry.With(key, value)
}
return entry
}
func (entry *Entry) WithContent(content []Content) *Entry {
entry.Content = append(entry.Content, content...)
return entry

View file

@ -65,7 +65,7 @@ func (formatter *FormatterJSON) Process(entry *Entry) {
}
}
func (formatter *FormatterJSON) End(_ *Entry) []byte {
func (formatter *FormatterJSON) End(entry *Entry) []byte {
// build JSON
data, err := json.Marshal(formatter.data)
if err != nil {

View file

@ -82,7 +82,7 @@ func (formatter *FormatterKeyValue) addKV(key string, value any) {
formatter.builder.WriteString(val)
}
func (formatter *FormatterKeyValue) End(_ *Entry) []byte {
func (formatter *FormatterKeyValue) End(entry *Entry) []byte {
// send data
return []byte(formatter.builder.String())
}

View file

@ -113,12 +113,6 @@ func (logger *Logger) With(key string, value any) *Entry {
return entry
}
func (logger *Logger) WithMap(entries map[string]any) *Entry {
entry := NewEntry(logger)
entry.WithMap(entries)
return entry
}
func (logger *Logger) WithContent(content []Content) *Entry {
entry := NewEntry(logger)
entry.WithContent(content)