Verlinkungen zu Beispielen eingefügt.

This commit is contained in:
SourceFellows
2020-10-21 06:05:47 +02:00
parent 264c517cec
commit ee1ecf0924
5 changed files with 194 additions and 0 deletions

View File

@ -1,10 +1,21 @@
package main
import (
"time"
log "github.com/sirupsen/logrus"
)
type Testing struct {
Val1 bool
Val2 string
Val3 time.Time
}
func main() {
log.SetFormatter(&log.JSONFormatter{})
// zusätzliche Felder an log.Entry anhängen
log.WithFields(log.Fields{
"importId": "ka18s",
@ -15,6 +26,7 @@ func main() {
contextLogger := log.WithFields(log.Fields{
"importId": "0815s",
"other": "Ich werde geloggt",
"test": Testing{Val3: time.Now()},
})
contextLogger.Info("I'll be logged with common and other field")
contextLogger.Info("Me too")