Go structured log syslog handler.
- Go >= 1.21
package main
import (
"log"
"log/slog"
slogsyslog "github.com/mocheryl/slog-syslog"
)
func main() {
h, err := slogsyslog.New(nil)
if err != nil {
log.Fatalf("Could not initialize syslog slog handler: %s\n", err)
return
}
logger := slog.New(h)
slog.SetDefault(l)
slog.Info("Hello, World!")
// Output: Jun 29 08:44:16 localhost helloworld[1234]: Hello, World!
h.Close()
}
Most of the code and ideas taken from the following projects:
- Structured log text handler from the standard library.
- Syslog client from the standard library.
- RackSpace Managed Security Development srslog.
- HashiCorp go-syslog.
Any contributions are welcome - see the CONTRIBUTING.md file for details.
This project is licensed under the 3-clause BSD license - see the LICENSE file for details.