nlog

package
v0.0.0-...-977ec7f Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 110

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicLumberjackLogger

func BasicLumberjackLogger(config *LogConfig) *lumberjack.Logger

func ChangeLogLevel

func ChangeLogLevel(level string) error

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(format string, args ...interface{})

func Setup

func Setup(ops ...Option)

func Sync

func Sync() error

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(format string, args ...interface{})

func Write

func Write(p []byte) (int, error)

Types

type Formatter

type Formatter interface {
	Format(context.Context, string) string
}

func NewDefaultFormatter

func NewDefaultFormatter() Formatter

func NewGinLogFormatter

func NewGinLogFormatter() Formatter

type Level

type Level int

A Level is a logging priority. Higher levels are more important.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel

	// InvalidLevel is an invalid value for Level.
	//
	// Core implementations may panic if they see messages of this level.
	InvalidLevel = _maxLevel + 1
)

type LogConfig

type LogConfig struct {
	LogLevel string
	LogPath  string

	// MaxFileSizeMB is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxFileSizeMB int

	// MaxFiles is the maximum number of old log files to retain.  The default
	// is to retain all old log files
	MaxFiles int

	Compress bool
}

type LogWriter

type LogWriter interface {
	Infof(format string, args ...interface{})
	Info(args ...interface{})

	Debugf(format string, args ...interface{})
	Debug(args ...interface{})

	Warnf(format string, args ...interface{})
	Warn(args ...interface{})

	Errorf(format string, args ...interface{})
	Error(args ...interface{})

	Fatalf(format string, args ...interface{})
	Fatal(args ...interface{})

	Sync() error
	Write(p []byte) (int, error)

	ChangeLogLevel(newLevel string) error
}

func GetDefaultLogWriter

func GetDefaultLogWriter() LogWriter

type NLog

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

func DefaultLogger

func DefaultLogger() *NLog

func NewNLog

func NewNLog(ops ...Option) *NLog

func WithCtx

func WithCtx(ctx context.Context) *NLog

func (*NLog) Debug

func (n *NLog) Debug(args ...interface{})

func (*NLog) Debugf

func (n *NLog) Debugf(format string, args ...interface{})

func (*NLog) Error

func (n *NLog) Error(args ...interface{})

func (*NLog) Errorf

func (n *NLog) Errorf(format string, args ...interface{})

func (*NLog) Fatal

func (n *NLog) Fatal(args ...interface{})

func (*NLog) Fatalf

func (n *NLog) Fatalf(format string, args ...interface{})

func (*NLog) Info

func (n *NLog) Info(args ...interface{})

func (*NLog) Infof

func (n *NLog) Infof(format string, args ...interface{})

func (*NLog) Warn

func (n *NLog) Warn(args ...interface{})

func (*NLog) Warnf

func (n *NLog) Warnf(format string, args ...interface{})

func (*NLog) WithCtx

func (n *NLog) WithCtx(ctx context.Context) *NLog

func (*NLog) Write

func (n *NLog) Write(p []byte) (int, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func SetFormatter

func SetFormatter(f Formatter) Option

func SetWriter

func SetWriter(w LogWriter) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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