log

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 5 Imported by: 0

README

go-level-log

A logger for Go with a support of levels.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLogger

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

BaseLogger is a base implementation of Logger interface.

func (*BaseLogger) Bind

func (l *BaseLogger) Bind(unit string, name string) Logger

Bind returns a new logger instance with the bound context.

func (*BaseLogger) Level

func (l *BaseLogger) Level() int

Level returns a log level.

func (*BaseLogger) Log

func (l *BaseLogger) Log(level int, useOutStream uint8, pairs ...interface{})

Log outputs a log record.

func (*BaseLogger) LogIf added in v0.2.0

func (l *BaseLogger) LogIf(condition bool, level int, useOutStream uint8, pairs ...interface{})

func (*BaseLogger) Name

func (l *BaseLogger) Name() string

Name returns a logged module instance name.

func (*BaseLogger) SetLevel

func (l *BaseLogger) SetLevel(level int)

SetLevel sets a log level.

func (*BaseLogger) SetName

func (l *BaseLogger) SetName(name string)

SetName updates a logged module instance name.

func (*BaseLogger) SetUnit

func (l *BaseLogger) SetUnit(unit string)

SetUnit updates a logged module name.

func (*BaseLogger) Unit

func (l *BaseLogger) Unit() string

Unit returns a logged module name.

type FmtLogger

type FmtLogger struct {
	BaseLogger
}

FmtLogger provides a user-friendly logger with formatting.

func (*FmtLogger) Bind

func (l *FmtLogger) Bind(unit string, name string) Logger

Bind returns a new logger instance with the bound context.

func (*FmtLogger) Log

func (l *FmtLogger) Log(level int, useOutStream uint8, pairs ...interface{})

Log outputs a log record.

func (*FmtLogger) LogIf added in v0.2.0

func (l *FmtLogger) LogIf(condition bool, level int, useOutStream uint8, pairs ...interface{})

type Logger

type Logger interface {
	Bind(unit string, name string) Logger
	Level() int
	SetLevel(level int)
	Name() string
	SetName(name string)
	Unit() string
	SetUnit(unit string)
	Log(level int, useOutStream uint8, pairs ...interface{})
	LogIf(condition bool, level int, useOutStream uint8, pairs ...interface{})
}

Logger provides a logger interface.

func NewBaseLogger

func NewBaseLogger(level int, unit string, name string) Logger

NewBaseLogger returns an initialized BaseLogger instance.

func NewFmtLogger

func NewFmtLogger(level int, unit string, name string) Logger

NewFmtLogger returns an initialized FmtLogger instance.

func NewNopLogger

func NewNopLogger(level int, unit string, name string) Logger

NewNopLogger creates an instance of NopLogger.

type NopLogger

type NopLogger struct {
	BaseLogger
}

NopLogger provides a stub for logger interface.

func (*NopLogger) Bind

func (l *NopLogger) Bind(unit string, name string) Logger

Bind returns a new logger instance with the bound context.

Jump to

Keyboard shortcuts

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