logging

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutoLogFile = "auto"
)

Variables

This section is empty.

Functions

func CloseFileHooks

func CloseFileHooks(l *logrus.Logger) error

CloseFileHooks will close each file being used for each FileHook attached to the logger. If the logger passed is nil, will reference the logrus.StandardLogger().

Types

type CLIHook

type CLIHook struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

CLIHook creates returns a hook which will log at the specified level.

func NewCLIHook

func NewCLIHook(w io.Writer, level logrus.Level) *CLIHook

func (*CLIHook) Fire

func (hook *CLIHook) Fire(entry *logrus.Entry) error

func (*CLIHook) Levels

func (hook *CLIHook) Levels() []logrus.Level

type FileHook

type FileHook struct {
	// Logger is a reference to the internal Logger that this utilizes.
	Logger *logrus.Logger

	// File is a reference to the file being written to.
	File *os.File

	// FilePath is the full path used when creating the file.
	FilePath string

	// Closed reports whether the hook has been closed. Once closed
	// it can't be written to again.
	Closed bool
}

FileHook to send logs to the trace file regardless of CLI level.

func GetFileHooks

func GetFileHooks(obj interface{}) []*FileHook

GetFileHooks is a convenience method to take an object and returns the FileHooks attached to it. Accepts an interface{} since the logger objects may be put into context or thread objects. The obj should be a *logrus.Logger object.

func GetFirstFileHook

func GetFirstFileHook(obj interface{}) *FileHook

GetFirstFileHook is a convenience method to take an object and returns the first FileHook attached to it. Accepts an interface{} since the logger objects may be put into context or thread objects. The obj should be a *logrus.Logger object.

func NewFileHook

func NewFileHook(path string) (*FileHook, error)

func (*FileHook) Fire

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

func (*FileHook) Levels

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

Jump to

Keyboard shortcuts

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