lo

package
v0.0.0-...-4873089 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LoglevelKey = "loglevel"
	LogdirKey   = "logdir"
	LogrusKey   = "logrus"

	LogTimeFormatKey     = "logTimeFormat"
	LogMaxBackupsDaysKey = "logMaxBackupsDays"
	LogDebugKey          = "logDebug"
)

Variables

View Source
var (

	// UserHome is the directory of user home directory.
	UserHome string
)

nolint gochecknoglobals

Functions

func DeclareLogFlags

func DeclareLogFlags()

DeclareLogFlags declares the log flags.

func DeclareLogPFlags

func DeclareLogPFlags()

DeclareLogPFlags declares the log pflags.

func Err

func Err(err error)

Err logs err if it is not nil

func Recover

func Recover()

Recover 在系统崩溃是,恢复系统

func SetupLog

func SetupLog() io.Writer

SetupLog setup log parameters.

func StartTicker

func StartTicker(interval time.Duration, f func() bool)

Types

type OptionFn

type OptionFn func(*RotateFile)

OptionFn defines options func prototype to set options for RotateFile.

func Debug

func Debug(debug bool) OptionFn

Debug defines debugf enabled or not.

func MaxBackupsDays

func MaxBackupsDays(maxBackupsDays int) OptionFn

MaxBackupsDays defines the max backups for the log files.

func TimeFormat

func TimeFormat(timeFormat string) OptionFn

TimeFormat defines the backup file's postfix, like 20060102(yyyyMMdd) or 15:04:05 (HH:mm:ss)

type RotateFile

type RotateFile struct {
	Filename       string
	MaxBackupsDays int

	TimeFormat string
	Debug      bool
	// contains filtered or unexported fields
}

RotateFile is a daily rotate file

func NewRotateFile

func NewRotateFile(filename string, optionFns ...OptionFn) (*RotateFile, error)

NewRotateFile create a daily rotation file

func (*RotateFile) Close

func (o *RotateFile) Close() error

Close closes the file

func (*RotateFile) Flush

func (o *RotateFile) Flush() error

Flush flushes the file

func (*RotateFile) Write

func (o *RotateFile) Write(d []byte) (int, error)

Write writes data to a file

type TextFormatter

type TextFormatter struct {
}

TextFormatter extends the prefixed.TextFormatter with line joining.

func (*TextFormatter) Format

func (f *TextFormatter) Format(e *logrus.Entry) ([]byte, error)

Format formats the log output.

Jump to

Keyboard shortcuts

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