Help us shape the future of Go! Take the 2026 Go Developer Survey

logging

package
v0.31.100 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Levels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERR"}

Levels are the log levels we respond to=o.

Functions

func Setup

func Setup(config *Config) error

Types

type Config

type Config struct {
	// Level is the log level to use.
	Level string `json:"level"`

	// LogFilePath is the path to the file the logs get written to
	LogFilePath string `json:"log_file"`

	// LogRotateBytes is the maximum number of bytes that should be written to a log
	// file
	LogRotateBytes int `json:"log_rotate_bytes"`

	// LogRotateDuration is the time after which log rotation needs to be performed
	LogRotateDuration time.Duration `json:"log_rotate_duration"`

	// LogRotateMaxFiles is the maximum number of log file archives to keep
	LogRotateMaxFiles int `json:"log_rotate_max_files"`

	// Syslog and SyslogFacility are the syslog configuration options.
	Syslog         bool   `json:"syslog"`
	SyslogFacility string `json:"syslog_facility"`
	// SyslogName is the progname as it will appear in syslog output (if enabled).
	SyslogName string `json:"name"`

	// Writer is the output where logs should go. If syslog is enabled, data will
	// be written to writer in addition to syslog.
	Writer io.Writer `json:"-"`
}

Config is the configuration for this log setup.

type LogFile added in v0.31.100

type LogFile struct {

	// LastCreated represents the creation time of the latest log
	LastCreated time.Time

	// FileInfo is the pointer to the current file being written to
	FileInfo *os.File

	// MaxBytes is the maximum number of desired bytes for a log file
	MaxBytes int

	// BytesWritten is the number of bytes written in the current log file
	BytesWritten int64

	// Max rotated files to keep before removing them.
	MaxFiles int
	// contains filtered or unexported fields
}

func (*LogFile) Write added in v0.31.100

func (l *LogFile) Write(b []byte) (int, error)

Write is used to implement io.Writer.

type SyslogWrapper

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

SyslogWrapper is used to cleanup log messages before writing them to a Syslogger. Implements the io.Writer interface.

func (*SyslogWrapper) Write

func (s *SyslogWrapper) Write(p []byte) (int, error)

Write is used to implement io.Writer.

Jump to

Keyboard shortcuts

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