logrus

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllLogType = map[LogType]string{
	DEBUG: "debug",
	INFO:  "info",
	WARN:  "warn",
	ERROR: "error",
	FATAL: "fatal",
}

AllLogType is a map of LogType to string names

Functions

func SetLogLevel

func SetLogLevel(name string)

Set minimum log level for messages

Types

type LogInfo

type LogInfo map[string]interface{}

LogInfo is an alias to extra info to log

type LogType

type LogType int

LogType is a typedef to represent the various log levels

const (
	DEBUG LogType = iota
	INFO
	WARN
	ERROR
	FATAL
)

These are our list of log levels

type Logger

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

Logger a logrus implementer of the JSON logger interface

func NewBasicLogrusLogger

func NewBasicLogrusLogger(context string) (*Logger, error)

NewBasicLogrusLogger creates a logrus logger with a context but no other options

func NewColorLogrusLogger

func NewColorLogrusLogger(context string) (*Logger, error)

NewColorLogrusLogger creates a logrus logger with a context and colorized output support

func NewLogrusLogger

func NewLogrusLogger(context string, info LogInfo, logger *logrus.Entry) (*Logger, error)

NewLogrusLogger return a LogrusLogger

func NoOpLogger

func NoOpLogger() (*Logger, *test.Hook)

func (*Logger) ActivityLog

func (l *Logger) ActivityLog(message string, info LogInfo)

ActivityLog is used for web activity logs

func (*Logger) ErrorLog

func (l *Logger) ErrorLog(message string, err error, info LogInfo)

ErrorLog log an error message

func (*Logger) Fatalf

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

Fatalf allows Fatalf'ing on the logger

func (*Logger) Log

func (l *Logger) Log(logType LogType, message string, info LogInfo)

Log logs a message on a particular log level

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

Print allows Printing on the logger

func (*Logger) Printf

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

Printf allows Printf'ing on the logger

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

Println allows Println'ing on the logger

func (*Logger) SetColorFormatter

func (l *Logger) SetColorFormatter(color bool)

SetColorFormatter sets logger to show colors on Unix and Windows systems

func (*Logger) SetJSONFormatter

func (l *Logger) SetJSONFormatter(json bool)

SetJSONFormatter sets logger to emit JSON or false => TextFormatter

func (*Logger) Write added in v0.2.2

func (l *Logger) Write(p []byte) (n int, err error)

Write implements the Write method of the io.Writer interface

Jump to

Keyboard shortcuts

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