logruseq

package module
v0.0.0-...-275e5c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2019 License: MIT Imports: 6 Imported by: 3

README

Logruseq

A Seq hook for Logrus

Build Status Go Report Card GoDoc

Install

go get -u github.com/nullseed/logruseq

Usage

package main

import (
	"github.com/nullseed/logruseq"
	log "github.com/sirupsen/logrus"
)

func main() {
	log.AddHook(logruseq.NewSeqHook("http://localhost:5341"))

	// Or optionally use the hook with an API key:
	// log.AddHook(logruseq.NewSeqHook("http://localhost:5341",
	// 	logruseq.OptionAPIKey("N1ncujiT5pYGD6m4CF0")))

	log.WithFields(log.Fields{
		"animal": "walrus",
	}).Info("A walrus appears")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionAPIKey

func OptionAPIKey(apiKey string) func(opts *SeqHookOptions)

OptionAPIKey sets the Seq API key option.

func OptionLevels

func OptionLevels(levels []logrus.Level) func(opts *SeqHookOptions)

OptionLevels sets the levels for which Fire will be called.

Types

type SeqHook

type SeqHook struct {
	// contains filtered or unexported fields
}

SeqHook sends logs to Seq via HTTP.

func NewSeqHook

func NewSeqHook(host string, opts ...func(*SeqHookOptions)) *SeqHook

NewSeqHook creates a Seq hook for logrus which can send log events to the host specified, for example:

logruseq.NewSeqHook("http://localhost:5341")

Optionally, the hook can be used with an API key, for example:

logruseq.NewSeqHook("http://localhost:5341",
    logruseq.OptionAPIKey("N1ncujiT5pYGD6m4CF0"))

Optionally, which levels to log can be specified:

logruseq.NewSeqHook("http://localhost:5341",
    logruseq.OptionLevels([]logrus.Level{
        logrus.WarnLevel,
        logrus.ErrorLevel,
        logrus.FatalLevel,
        logrus.PanicLevel,
    }))

func (*SeqHook) Fire

func (hook *SeqHook) Fire(entry *logrus.Entry) error

Fire sends a log entry to Seq.

func (*SeqHook) Levels

func (hook *SeqHook) Levels() []logrus.Level

Levels returns the levels for which Fire will be called.

type SeqHookOptions

type SeqHookOptions struct {
	// contains filtered or unexported fields
}

SeqHookOptions collects non-default Seq hook options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL