30 lines
677 B
Go
30 lines
677 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.martin-riedl.de/golang/log"
|
|
)
|
|
|
|
func main() {
|
|
advancedSettings()
|
|
}
|
|
|
|
func advancedSettings() {
|
|
// Key Value Formatter with special settings
|
|
formatter := log.NewFormatterKeyValue()
|
|
formatter.HighPriorityKeys = []string{"firstField"}
|
|
formatter.PriorityKeys = []string{"secondField"}
|
|
formatter.TimeFormat = time.RFC3339Nano
|
|
|
|
// create new log instance
|
|
output := log.NewOutput(log.LevelDebug, formatter, log.NewPrinterStdout())
|
|
logger := log.NewLogger([]*log.Output{output})
|
|
|
|
// log some message
|
|
logger.WithMap(log.Map{
|
|
"someField": "Martin",
|
|
"firstField": "John",
|
|
"secondField": "Doe",
|
|
}).Info("This is an info message")
|
|
}
|