mlog

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggerWriter

func NewLoggerWriter(logger *log.Logger, prefix string) io.WriteCloser

NewLoggerWriter create a new io.WriteCloser that append each line to log.procLogger

func NewRotatingFile

func NewRotatingFile(opts RotatingFileOptions) (w io.WriteCloser, err error)

NewRotatingFile create a new io.WriteCloser as a rotating log file

Types

type Output

type Output interface {
	// WriteCloser is for single line writing
	io.WriteCloser

	// ReaderFrom is for streaming
	io.ReaderFrom
}

Output interface for single stream log output

func MultiOutput

func MultiOutput(outputs ...Output) Output

MultiOutput create a new Output for proc logging

func NewWriterOutput

func NewWriterOutput(w io.Writer, pfx, sfx []byte) Output

NewWriterOutput wrap a writer as a Output, with optional line Prefix and Suffix

type ProcLogger

type ProcLogger interface {
	Print(items ...interface{})
	Printf(layout string, items ...interface{})
	Error(items ...interface{})
	Errorf(layout string, items ...interface{})

	ProcOutput
}

func CreateSimpleLogger added in v1.15.1

func CreateSimpleLogger(dir string, name string, pfx string) (ProcLogger, error)

func NewProcLogger

func NewProcLogger(opts ProcLoggerOptions) (pl ProcLogger, err error)

type ProcLoggerOptions

type ProcLoggerOptions struct {
	ConsoleOut    io.Writer
	ConsoleErr    io.Writer
	ConsolePrefix string

	FilePrefix  string
	FileOptions *RotatingFileOptions
}

type ProcOutput

type ProcOutput interface {
	// Out stdout
	Out() Output
	// Err stderr
	Err() Output
}

ProcOutput interface for process

type RotatingFileOptions

type RotatingFileOptions struct {
	// Dir directory
	Dir string
	// Filename filename prefix
	Filename string
	// MaxFileSize max size of a single file, default to 128mb
	MaxFileSize int64
	// MaxFileCount max count of rotated files
	MaxFileCount int64
}

RotatingFileOptions options for creating a RotatingFile

Jump to

Keyboard shortcuts

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