log

package
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 4 Imported by: 38

Documentation

Index

Constants

View Source
const (
	// LevelAll enables all logs.
	LevelAll = iota
	// LevelDebug is for debug logs, usually disabled in production.
	LevelDebug
	// LevelInfo is the default level.
	LevelInfo
	// LevelWarn is for warnings.
	LevelWarn
	// LevelError is for errors.
	LevelError
	// LevelNone disables all logs.
	LevelNone
)

Variables

View Source
var (
	// TimeFormat is the timestamp layout of each log line.
	TimeFormat = "2006/01/02 15:04:05.000"

	// Output is where the default logger writes to.
	Output io.Writer = os.Stdout

	// DefaultLogger is the logger used by arpc, at LevelInfo by default.
	DefaultLogger Logger = &logger{level: LevelInfo}
)

Functions

func Debug

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

Debug logs a message at LevelDebug via DefaultLogger, if it is not nil.

func Error

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

Error logs a message at LevelError via DefaultLogger, if it is not nil.

func Info

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

Info logs a message at LevelInfo via DefaultLogger, if it is not nil.

func SetLevel

func SetLevel(lvl int)

SetLevel sets the level of DefaultLogger. An invalid level is reported to Output and ignored.

func SetLogger

func SetLogger(l Logger)

SetLogger replaces DefaultLogger.

func Warn

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

Warn logs a message at LevelWarn via DefaultLogger, if it is not nil.

Types

type Logger

type Logger interface {
	SetLevel(lvl int)
	Debug(format string, v ...interface{})
	Info(format string, v ...interface{})
	Warn(format string, v ...interface{})
	Error(format string, v ...interface{})
}

Logger is the logging interface used by arpc.

Jump to

Keyboard shortcuts

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