cuslog

package
v0.0.0-...-5ca63f1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FmtEmptySeparate = ""
)

Variables

View Source
var LevelNameMapping = map[Level]string{
	DebugLevel: "DEBUG",
	InfoLevel:  "INFO",
	WarnLevel:  "WARN",
	ErrorLevel: "ERROR",
	PanicLevel: "PANIC",
	FatalLevel: "FATAL",
}

log level string name mapping

Functions

func Debug

func Debug(args ...any)

std logger

func Debugf

func Debugf(format string, args ...any)

func Error

func Error(args ...any)

func Errorf

func Errorf(format string, args ...any)

func Fatal

func Fatal(args ...any)

func Fatalf

func Fatalf(format string, args ...any)

func Info

func Info(args ...any)

func Infof

func Infof(format string, args ...any)

func Panic

func Panic(args ...any)

func Panicf

func Panicf(format string, args ...any)

func SetOptions

func SetOptions(opts ...Option)

func Warn

func Warn(args ...any)

func Warnf

func Warnf(format string, args ...any)

func Writer

func Writer() io.Writer

Types

type Entry

type Entry struct {
	Buffer *bytes.Buffer
	Map    map[string]any
	Level  Level
	Time   time.Time
	File   string
	Line   int
	Func   string
	Format string
	Args   []any
	// contains filtered or unexported fields
}

type Formatter

type Formatter interface {
	// Format Maybe in async goroutine
	// Please write the result to buffer
	Format(entry *Entry) error
}

type JsonFormatter

type JsonFormatter struct {
	IgnoreBasicFields bool
}

func (*JsonFormatter) Format

func (f *JsonFormatter) Format(e *Entry) error

type Level

type Level uint8

log level

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
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

const log level

func (*Level) UnmarshalText

func (l *Level) UnmarshalText(text []byte) error

UnmarshalText unmarshal text to a level.

type Logger

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

func New

func New(opts ...Option) *Logger

func StdLogger

func StdLogger() *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Error

func (l *Logger) Error(args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(args ...any)

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...any)

func (*Logger) Info

func (l *Logger) Info(args ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

func (*Logger) Panic

func (l *Logger) Panic(args ...any)

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...any)

func (*Logger) SetOptions

func (l *Logger) SetOptions(opts ...Option)

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

func (*Logger) Write

func (l *Logger) Write(data []byte) (int, error)

func (*Logger) Writer

func (l *Logger) Writer() io.Writer

type Option

type Option func(*options)

func WithDisableCaller

func WithDisableCaller(caller bool) Option

func WithFormatter

func WithFormatter(formatter Formatter) Option

func WithLevel

func WithLevel(level Level) Option

func WithOutput

func WithOutput(output io.Writer) Option

func WithStdLevel

func WithStdLevel(level Level) Option

type TextFormatter

type TextFormatter struct {
	IgnoreBasicFields bool
}

func (*TextFormatter) Format

func (f *TextFormatter) Format(e *Entry) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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