logger

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 1 Imported by: 0

README

Hooks for logrus

Example

package main

import (
  "net/http"
  
  "github.com/onrik/logrus/filename"
  "github.com/onrik/logrus/sentry"
  log "github.com/sirupsen/logrus"
)

var (
  dsn = "http://60a0257d7b5a429a8838e5f2ba873ec9@example.com/1"
)

func main() {
  filenameHook := filename.NewHook()
  filenameHook.Field = "custom_source_field" // Customize source field name
  log.AddHook(filenameHook)
  
  log.AddHook(sentry.NewHook(sentry.Options{
    Dsn: dsn,
  }, log.PanicLevel, log.FatalLevel, log.ErrorLevel))
  
  log.WithError(err).Error("Dead beef")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter struct {
	Fields log.Fields
	LF     log.Formatter
}

Formatter adds default fields to each log entry.

func (*Formatter) Format

func (f *Formatter) Format(e *log.Entry) ([]byte, error)

Format satisfies the logrus.Formatter interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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