Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Socket hook for logrus

License

Notifications You must be signed in to change notification settings

Showmax/sockrus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socket hook for logrus :walrus:

GoDoc

Use this hook to send the logs over UDP, TCP or Unix socket.

Output format is JSON, formatted for Logstash/ElasticSearch.

Usage

package main

import (
        "github.com/sirupsen/logrus"
        "github.com/Showmax/sockrus"
)

func main() {
        log := logrus.New()
        hook, err := sockrus.NewHook("unixpacket", "/tmp/log.sock")
        if err != nil {
                log.Fatal(err)
        }
        log.Hooks.Add(hook)
        ctx := log.WithFields(logrus.Fields{
          "method": "main",
        })
        ...
        ctx.Info("Hello World!")
}

This is how it will look like:

{
  "@timestamp": "2016-04-15T12:49:36Z",
  "@version": 1,
  "level": "info",
  "message": "Hello World!",
  "method": "main"
}

About

Socket hook for logrus

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%