logging

package
v19.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogRoot              = "/var/log/" + config.OrchestratorName
	LogRotationThreshold = 10485760 // 10 MB
	MaxLogEntryLength    = 64000
	RandomLogcheckEnvVar = "LOGROTATE_FREQUENCY"
)
View Source
const (
	TextFormat = "text"
	JSONFormat = "json"
)

Variables

This section is empty.

Functions

func InitLogFormat

func InitLogFormat(logFormat string) error

InitLogFormat configures the log format, allowing a choice of text or JSON.

func InitLogLevel

func InitLogLevel(debug bool, logLevel string) error

InitLogLevel configures the logging level. The debug flag takes precedence if set, otherwise the logLevel flag (debug, info, warn, error, fatal) is used.

func InitLoggingForDocker

func InitLoggingForDocker(logName, logFormat string) error

InitLoggingForDocker configures logging for nDVP. Logs are written both to a log file as well as stdout/stderr. Since logrus doesn't support multiple writers, each log stream is implemented as a hook.

Types

type ConsoleHook

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

ConsoleHook sends log entries to stdout.

func NewConsoleHook

func NewConsoleHook(logFormat string) (*ConsoleHook, error)

NewConsoleHook creates a new log hook for writing to stdout/stderr.

func (*ConsoleHook) Fire

func (hook *ConsoleHook) Fire(entry *log.Entry) error

func (*ConsoleHook) Levels

func (hook *ConsoleHook) Levels() []log.Level

type FileHook

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

FileHook sends log entries to a file.

func NewFileHook

func NewFileHook(logName, logFormat string) (*FileHook, error)

NewFileHook creates a new log hook for writing to a file.

func (*FileHook) Fire

func (hook *FileHook) Fire(entry *log.Entry) error

func (*FileHook) GetLocation

func (hook *FileHook) GetLocation() string

func (*FileHook) Levels

func (hook *FileHook) Levels() []log.Level

type JSONFormatter

type JSONFormatter struct {
	// TimestampFormat sets the format used for marshaling timestamps.
	TimestampFormat string
	// DisableTimestamp allows disabling automatic timestamps in output
	DisableTimestamp bool
	// PrettyPrint will indent all json logs
	PrettyPrint bool
}

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *log.Entry) ([]byte, error)

type PlainTextFormatter

type PlainTextFormatter struct {

	// TimestampFormat to use for display when a full timestamp is printed
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool
}

PlainTextFormatter is a formatter than does no coloring *and* does not insist on writing logs as key/value pairs.

func (*PlainTextFormatter) Format

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

Jump to

Keyboard shortcuts

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