logger

package
v0.0.0-...-c415e3a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// LogTypeLog is normal log type.
	LogTypeLog = "log"
	// LogTypeRequest is Request log type.
	LogTypeRequest = "request"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug.

func Debugf

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

Debugf logs a message at level Debug.

func Error

func Error(args ...interface{})

Error logs a message at level Error.

func Errorf

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

Errorf logs a message at level Error.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal then the process will exit with status set to 1.

func Fatalf

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

Fatalf logs a message at level Fatal then the process will exit with status set to 1.

func Info

func Info(args ...interface{})

Info logs a message at level Info.

func Infof

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

Infof logs a message at level Info.

func Init

func Init(name string, options ...Option)

func NewLogger

func NewLogger(name string, options ...Option) *logger

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn.

func Warnf

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

Warnf logs a message at level Warn.

Types

type LogLevel

type LogLevel string

LogLevel is Logger Level type.

const (
	// DebugLevel has verbose message.
	DebugLevel LogLevel = "debug"
	// InfoLevel is default log level.
	InfoLevel LogLevel = "info"
	// WarnLevel is for logging messages about possible issues.
	WarnLevel LogLevel = "warn"
	// ErrorLevel is for logging errors.
	ErrorLevel LogLevel = "error"
	// FatalLevel is for logging fatal messages. The system shuts down after logging the message.
	FatalLevel LogLevel = "fatal"

	// UndefinedLevel is for undefined log level.
	UndefinedLevel LogLevel = "undefined"
)

type Logger

type Logger interface {
	// Info logs a message at level Info.
	Info(args ...interface{})
	// Infof logs a message at level Info.
	Infof(format string, args ...interface{})
	// Debug logs a message at level Debug.
	Debug(args ...interface{})
	// Debugf logs a message at level Debug.
	Debugf(format string, args ...interface{})
	// Warn logs a message at level Warn.
	Warn(args ...interface{})
	// Warnf logs a message at level Warn.
	Warnf(format string, args ...interface{})
	// Error logs a message at level Error.
	Error(args ...interface{})
	// Errorf logs a message at level Error.
	Errorf(format string, args ...interface{})
	// Fatal logs a message at level Fatal then the process will exit with status set to 1.
	Fatal(args ...interface{})
	// Fatalf logs a message at level Fatal then the process will exit with status set to 1.
	Fatalf(format string, args ...interface{})
}

Logger includes the logging api sets.

type Option

type Option func(l *logger) error

Option defines the sets of option for logging.

func WithOutputFormat

func WithOutputFormat(enableJson bool) Option

WithOutputLevel sets the log output format.

func WithOutputLevel

func WithOutputLevel(outputLevel LogLevel) Option

WithOutputLevel sets the log output level.

func WithOutputLevelString

func WithOutputLevelString(outputLevel string) Option

WithOutputLevelString sets the log output level by string.

Jump to

Keyboard shortcuts

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