Skip to content

bin3377/logrus-datadog-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logrus-datadog-hook

Shipping log entries from logrus to Datadog log API HTTP endpoint

Example

    hostName, _ := os.Hostname()
    // Sending log in JSON, batch log every 5 sec and when failure, retry up to 3 times
    hook := NewHook(host, apiKey, 5*time.Second, 3, logrus.TraceLevel, &logrus.JSONFormatter{}, Options{Hostname: hostName})
    l := logrus.New()
    l.Hooks.Add(hook)
    l.WithField("from", "unitest").Infof("TestSendingJSON - %d", i)