logger

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 9 Imported by: 98

README

Logger

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/logger

Getting Started

logger.Debug("Hi, %s", "Goo Zoox")
logger.Info("Hi, %s", "Goo Zoox")
logger.Warn("Hi, %s", "Goo Zoox")
logger.Error("Hi, %s", "Goo Zoox")
logger.Fatal("Hi, %s", "Goo Zoox")

// set level
logger.SetLevel("error")

Inspired by

License

GoZoox is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LevelDebug is Level Debug
	LevelDebug = constants.LevelDebug
	// LevelInfo is Level Info
	LevelInfo = constants.LevelInfo
	// LevelWarn is Level Warn
	LevelWarn = constants.LevelWarn
	// LevelError is Level Error
	LevelError = constants.LevelError
	// LevelFatal is Level Fatal
	LevelFatal = constants.LevelFatal
)
View Source
var LogLevelEnv = "LOG_LEVEL"

LogLevelEnv ...

View Source
var Version = "1.5.1"

Version returns the current version of the logger.

Functions

func AppendTransports added in v1.3.3

func AppendTransports(transports map[string]cst.Transport) error

AppendTransports appends the transports of the logger.

func Debug

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

Debug logs a debug message.

func Debugf added in v1.1.5

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

Debugf logs a debug message.

func Error

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

Error logs an error message.

func Errorf added in v1.1.5

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

Errorf logs an error message.

func Fatal

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

Fatal logs a fatal message.

func Fatalf added in v1.1.5

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

Fatalf logs a fatal message.

func GetLevel added in v1.4.6

func GetLevel() string

GetLevel returns the level of the logger.

func Info

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

Info logs an info message.

func Infof added in v1.1.5

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

Infof logs an info message.

func IsDebugLevel added in v1.4.6

func IsDebugLevel() bool

IsDebugLevel returns true if the logger level is debug.

func IsErrorLevel added in v1.4.6

func IsErrorLevel() bool

IsErrorLevel returns true if the logger level is error.

func IsFatalLevel added in v1.4.6

func IsFatalLevel() bool

IsFatalLevel returns true if the logger level is fatal.

func IsInfoLevel added in v1.4.6

func IsInfoLevel() bool

IsInfoLevel returns true if the logger level is info.

func IsWarnLevel added in v1.4.6

func IsWarnLevel() bool

IsWarnLevel returns true if the logger level is warn.

func Now added in v1.1.0

func Now() string

Now returns the current time string.

func SetLevel

func SetLevel(level string) (err error)

SetLevel sets the level of the logger.

func SetTransports added in v1.3.3

func SetTransports(transports map[string]cst.Transport) error

SetTransports sets the transports of the logger.

it will overrides system transport, if you only want append transport, just use AppendTransports.

func Warn

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

Warn logs a warning message.

func Warnf added in v1.1.5

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

Warnf logs a warning message.

Types

type Logger added in v1.1.0

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

Logger is the main logger object.

func New

func New(options ...*Options) *Logger

New creates a new logger object.

func (*Logger) AppendTransports added in v1.3.3

func (l *Logger) AppendTransports(transports map[string]cst.Transport) error

AppendTransports appends the transports of the logger.

func (*Logger) Debug added in v1.1.0

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

Debug logs a debug message.

func (*Logger) Debugf added in v1.3.2

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

Debugf logs a debug message.

func (*Logger) Error added in v1.1.0

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

Error logs an error message.

func (*Logger) Errorf added in v1.3.2

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

Errorf logs an error message.

func (*Logger) Fatal added in v1.1.0

func (l *Logger) Fatal(format string, v ...interface{})

Fatal logs a fatal message.

func (*Logger) Fatalf added in v1.3.2

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

Fatalf logs a fatal message.

func (*Logger) GetLevel added in v1.4.6

func (l *Logger) GetLevel() string

GetLevel gets the level of the logger.

func (*Logger) Info added in v1.1.0

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

Info logs an info message.

func (*Logger) Infof added in v1.3.2

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

Infof logs an info message.

func (*Logger) IsDebugLevel added in v1.4.6

func (l *Logger) IsDebugLevel() bool

IsDebugLevel returns true if the logger level is debug.

func (*Logger) IsErrorLevel added in v1.4.6

func (l *Logger) IsErrorLevel() bool

IsErrorLevel returns true if the logger level is error.

func (*Logger) IsFatalLevel added in v1.4.6

func (l *Logger) IsFatalLevel() bool

IsFatalLevel returns true if the logger level is fatal.

func (*Logger) IsInfoLevel added in v1.4.6

func (l *Logger) IsInfoLevel() bool

IsInfoLevel returns true if the logger level is info.

func (*Logger) IsWarnLevel added in v1.4.6

func (l *Logger) IsWarnLevel() bool

IsWarnLevel returns true if the logger level is warn.

func (*Logger) Printf added in v1.4.5

func (l *Logger) Printf(format string, v ...interface{})

Printf logs a message.

func (*Logger) SetLevel added in v1.1.0

func (l *Logger) SetLevel(level string) error

SetLevel sets the level of the logger.

func (*Logger) SetTimeFormat added in v1.1.1

func (l *Logger) SetTimeFormat(format string)

SetTimeFormat sets the time format.

func (*Logger) SetTransports added in v1.3.3

func (l *Logger) SetTransports(transports map[string]cst.Transport) error

SetTransports sets the transports of the logger.

it will overrides system transport, if you only want append transport, just use AppendTransports.

func (*Logger) Warn added in v1.1.0

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

Warn logs a warning message.

func (*Logger) Warnf added in v1.3.2

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

Warnf logs a warning message.

func (*Logger) Write added in v1.4.0

func (l *Logger) Write(p []byte) (n int, err error)

Write realizes io.Writer

type Options added in v1.1.0

type Options struct {
	Level      string
	Transports map[string]cst.Transport
	TimeFormat string
}

Options is the options for the logger.

Directories

Path Synopsis
components
transport

Jump to

Keyboard shortcuts

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