log

package
v0.0.0-...-e6f4ba9 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextreqIDKey is Request Context Value key for debug logging
	ContextreqIDKey = ContextKey("ContextreqIDKey")
)

Variables

View Source
var LogLevelMap = map[string]logrus.Level{
	"Panic": logrus.PanicLevel,
	"Fatal": logrus.FatalLevel,
	"Error": logrus.ErrorLevel,
	"Warn":  logrus.WarnLevel,
	"Info":  logrus.InfoLevel,
	"Debug": logrus.DebugLevel,
}

LogLevelMap is string map of log levels

View Source
var SyslogFacilityMap = map[string]syslog.Priority{
	"LOG_KERN":     syslog.LOG_KERN,
	"LOG_USER":     syslog.LOG_USER,
	"LOG_MAIL":     syslog.LOG_MAIL,
	"LOG_DAEMON":   syslog.LOG_DAEMON,
	"LOG_AUTH":     syslog.LOG_AUTH,
	"LOG_SYSLOG":   syslog.LOG_SYSLOG,
	"LOG_LPR":      syslog.LOG_LPR,
	"LOG_NEWS":     syslog.LOG_NEWS,
	"LOG_UUCP":     syslog.LOG_UUCP,
	"LOG_CRON":     syslog.LOG_CRON,
	"LOG_AUTHPRIV": syslog.LOG_AUTHPRIV,
	"LOG_FTP":      syslog.LOG_FTP,
	"LOG_LOCAL0":   syslog.LOG_LOCAL0,
	"LOG_LOCAL1":   syslog.LOG_LOCAL1,
	"LOG_LOCAL2":   syslog.LOG_LOCAL2,
	"LOG_LOCAL3":   syslog.LOG_LOCAL3,
	"LOG_LOCAL4":   syslog.LOG_LOCAL4,
	"LOG_LOCAL5":   syslog.LOG_LOCAL5,
	"LOG_LOCAL6":   syslog.LOG_LOCAL6,
	"LOG_LOCAL7":   syslog.LOG_LOCAL7,
}

SyslogFacilityMap is string map of facilities

Functions

func Debug

func Debug(v ...interface{})

Debug calls DefaultLogger

func Debugf

func Debugf(format string, v ...interface{})

Debugf calls DefaultLogger

func Debugln

func Debugln(v ...interface{})

Debugln calls DefaultLogger

func Fatal

func Fatal(v ...interface{})

Fatal calls DefaultLogger

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf calls DefaultLogger

func Fatalln

func Fatalln(v ...interface{})

Fatalln calls DefaultLogger

func Panic

func Panic(v ...interface{})

Panic calls DefaultLogger

func Panicf

func Panicf(format string, v ...interface{})

Panicf calls DefaultLogger

func Panicln

func Panicln(v ...interface{})

Panicln calls DefaultLogger

func Print

func Print(v ...interface{})

Print calls DefaultLogger

func Printf

func Printf(format string, v ...interface{})

Printf calls DefaultLogger

func Println

func Println(v ...interface{})

Println calls DefaultLogger

Types

type BrimLogHook

type BrimLogHook struct {
	Creds Credentials `json:"Credentials"`
	Host  string      `json:"Host"`
	Path  string      `json:"Path"`
}

BrimLogHook collects and sends sync events to brim api

func (*BrimLogHook) Fire

func (lh *BrimLogHook) Fire(entry *logrus.Entry) (err error)

Fire for logrus.Hook interface compliance

func (*BrimLogHook) Levels

func (lh *BrimLogHook) Levels() []logrus.Level

Levels for logrus.Hook interface complience

type ContextKey

type ContextKey string

ContextKey is type for log related context keys

type Credentials

type Credentials struct {
	User string `json:"User"`
	Pass string `json:"Pass"`
}

Credentials stores brim api credentials

type Logger

type Logger interface {
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})

	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})

	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})

	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Debugln(v ...interface{})
}

Logger interface generalizes Logger implementations

var DefaultLogger Logger = logrus.New()

DefaultLogger ...

func NewDefaultLogger

func NewDefaultLogger(config LoggerConfig, syslogFacility string, plainText bool) (Logger, error)

NewDefaultLogger return configured Logger or syslog logger

func NewLogger

func NewLogger(config LoggerConfig) (Logger, error)

NewLogger creates Logger

type LoggerConfig

type LoggerConfig struct {
	Stderr    bool         `yaml:"stderr,omitempty"`
	PlainText bool         `yaml:"plaintext,omitempty"`
	Stdout    bool         `yaml:"stdout,omitempty"`
	File      string       `yaml:"file"`
	Syslog    string       `yaml:"syslog"`
	Database  sql.DBConfig `yaml:"database"`
	BrimAPI   BrimLogHook  `yaml:"brim"`
	Level     string       `yaml:"level"`
}

LoggerConfig holds oprions

type PlainTextFormatter

type PlainTextFormatter struct{}

PlainTextFormatter implements raw message formatting

func (PlainTextFormatter) Format

func (f PlainTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format implements logrus.Formatter interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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