log

package
v0.0.88 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package log provides the core logger functions. Basically, this is a wrapper of log.Logger

Index

Constants

View Source
const LoggerContextKey = LoggerContext("LoggerContext")

LoggerContextKey is the key of context for get/set Logger

Variables

This section is empty.

Functions

func NewContextWithLogger added in v0.0.87

func NewContextWithLogger(ctx context.Context, level int) context.Context

NewContextWithLogger returns a new context with given logger level

Types

type ContextAware

type ContextAware interface {
	// Context returns the instance of context.Context
	Context() context.Context
}

ContextAware is the interface for getting context.Context

type LevelLog

type LevelLog struct {
	*syslog.Logger
	// contains filtered or unexported fields
}

LevelLog is the wrapper of built-in log.Logger

func GetLogger

func GetLogger() *LevelLog

GetLogger returns an instance of Logger

func GetLoggerFromContextOrDefault

func GetLoggerFromContextOrDefault(aware ContextAware) (logger *LevelLog)

GetLoggerFromContextOrDefault returns a Logger instance from context, or a default instance if no Logger in the context

func (*LevelLog) Debug

func (l *LevelLog) Debug(v ...any)

Debug prints the debug level message. Debug level means the level >= 7

func (*LevelLog) GetLevel added in v0.0.87

func (l *LevelLog) GetLevel() int

GetLevel returns the level of logger

func (*LevelLog) Info

func (l *LevelLog) Info(v ...any)

Info prints the info level message. Info level means the level >= 3

func (*LevelLog) SetLevel added in v0.0.87

func (l *LevelLog) SetLevel(level int) *LevelLog

SetLevel sets the level of logger

func (*LevelLog) SetOutput added in v0.0.87

func (l *LevelLog) SetOutput(writer io.Writer) *LevelLog

SetOutput sets the output destination for the logger.

type LoggerContext

type LoggerContext string

LoggerContext used to get and set context value

Jump to

Keyboard shortcuts

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