klog

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 5 Imported by: 1,047

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxDebugf added in v0.1.0

func CtxDebugf(ctx context.Context, format string, v ...interface{})

CtxDebugf calls the default logger's CtxDebugf method.

func CtxErrorf added in v0.1.0

func CtxErrorf(ctx context.Context, format string, v ...interface{})

CtxErrorf calls the default logger's CtxErrorf method.

func CtxFatalf added in v0.1.0

func CtxFatalf(ctx context.Context, format string, v ...interface{})

CtxFatalf calls the default logger's CtxFatalf method and then os.Exit(1).

func CtxInfof added in v0.1.0

func CtxInfof(ctx context.Context, format string, v ...interface{})

CtxInfof calls the default logger's CtxInfof method.

func CtxNoticef added in v0.1.0

func CtxNoticef(ctx context.Context, format string, v ...interface{})

CtxNoticef calls the default logger's CtxNoticef method.

func CtxTracef added in v0.1.0

func CtxTracef(ctx context.Context, format string, v ...interface{})

CtxTracef calls the default logger's CtxTracef method.

func CtxWarnf added in v0.1.0

func CtxWarnf(ctx context.Context, format string, v ...interface{})

CtxWarnf calls the default logger's CtxWarnf method.

func Debug

func Debug(v ...interface{})

Debug calls the default logger's Debug method.

func Debugf

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

Debugf calls the default logger's Debugf method.

func Error

func Error(v ...interface{})

Error calls the default logger's Error method.

func Errorf

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

Errorf calls the default logger's Errorf method.

func Fatal

func Fatal(v ...interface{})

Fatal calls the default logger's Fatal method and then os.Exit(1).

func Fatalf

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

Fatalf calls the default logger's Fatalf method and then os.Exit(1).

func Info

func Info(v ...interface{})

Info calls the default logger's Info method.

func Infof

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

Infof calls the default logger's Infof method.

func Notice

func Notice(v ...interface{})

Notice calls the default logger's Notice method.

func Noticef

func Noticef(format string, v ...interface{})

Noticef calls the default logger's Noticef method.

func SetLevel

func SetLevel(lv Level)

SetLevel sets the level of logs below which logs will not be output. The default log level is LevelTrace. Note that this method is not concurrent-safe.

func SetLogger added in v0.1.0

func SetLogger(v FullLogger)

SetLogger sets the default logger. Note that this method is not concurrent-safe and must not be called after the use of DefaultLogger and global functions in this package.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output of default logger. By default, it is stderr.

func Trace

func Trace(v ...interface{})

Trace calls the default logger's Trace method.

func Tracef

func Tracef(format string, v ...interface{})

Tracef calls the default logger's Tracef method.

func Warn

func Warn(v ...interface{})

Warn calls the default logger's Warn method.

func Warnf

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

Warnf calls the default logger's Warnf method.

Types

type Control added in v0.1.0

type Control interface {
	SetLevel(Level)
	SetOutput(io.Writer)
}

Control provides methods to config a logger.

type CtxLogger

type CtxLogger interface {
	CtxTracef(ctx context.Context, format string, v ...interface{})
	CtxDebugf(ctx context.Context, format string, v ...interface{})
	CtxInfof(ctx context.Context, format string, v ...interface{})
	CtxNoticef(ctx context.Context, format string, v ...interface{})
	CtxWarnf(ctx context.Context, format string, v ...interface{})
	CtxErrorf(ctx context.Context, format string, v ...interface{})
	CtxFatalf(ctx context.Context, format string, v ...interface{})
}

CtxLogger is a logger interface that accepts a context argument and output logs with a format.

type FormatLogger

type FormatLogger interface {
	Tracef(format string, v ...interface{})
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Noticef(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Fatalf(format string, v ...interface{})
}

FormatLogger is a logger interface that output logs with a format.

type FullLogger added in v0.1.0

type FullLogger interface {
	Logger
	FormatLogger
	CtxLogger
	Control
}

FullLogger is the combination of Logger, FormatLogger, CtxLogger and Control.

func DefaultLogger

func DefaultLogger() FullLogger

DefaultLogger return the default logger for kitex.

type Level

type Level int

Level defines the priority of a log message. When a logger is configured with a level, any log message with a lower log level (smaller by integer comparison) will not be output.

const (
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelNotice
	LevelWarn
	LevelError
	LevelFatal
)

The levels of logs.

type Logger

type Logger interface {
	Trace(v ...interface{})
	Debug(v ...interface{})
	Info(v ...interface{})
	Notice(v ...interface{})
	Warn(v ...interface{})
	Error(v ...interface{})
	Fatal(v ...interface{})
}

Logger is a logger interface that provides logging function with levels.

Jump to

Keyboard shortcuts

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