log icon indicating copy to clipboard operation
log copied to clipboard

#81: syslog handler

Open nergdron opened this issue 5 years ago • 1 comments

This is my first pass at implementing this handler. I wrote a quick little test script which seems to produce the behaviour I expect, but I welcome feedback on it.

package main

import (
  "errors"
  stdlog "log"
  "github.com/apex/log"
  "github.com/apex/log/handlers/syslog"
)

func main() {
  h, err := syslog.New("", 0, "test")
  if err != nil {
    stdlog.Fatal(err)
  }
  log.SetHandler(h)
  log.WithError(errors.New("errormsg")).WithFields(log.Fields{
		"app": "myapp",
		"env": "prod",
	}).Warn("something went wrong\nunfortunately")
}

nergdron avatar Jul 05 '20 22:07 nergdron

@tj: ok, I think that works alright, how's this look to you?

nergdron avatar Jul 22 '20 20:07 nergdron