log

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: MIT Imports: 8 Imported by: 70

README

Simple logger

Simple logger for Go services

Documentation

Index

Constants

View Source
const DefaultLevel = Info

DefaultLevel represents the default log level.

View Source
const EnvLevel = "LOG_LEVEL"

EnvLevel holds the name of environment variable for the log level. It's here for the convenience.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level uint32

Level defines the log Level.

const (
	Info Level = iota
	Warning
	Error
	Critical
)

The list of available log levels.

func ParseLevel

func ParseLevel(s string) (Level, error)

ParseLevel parses the level string. If the name of level is unknown it returns an error and the default level.

func (Level) String

func (l Level) String() string

String returns a string representation of log level.

type Logger

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

Logger defines the properties of the logger.

func New

func New() *Logger

New creates a new Logger with the output assigned to stderr and the default log level.

func (*Logger) Critical

func (l *Logger) Critical(v ...interface{})

Critical prints to the logger at "Critical" log level.

func (*Logger) Criticalf

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

Criticalf prints formatted output to the logger at "Critical" log level.

func (*Logger) Error

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

Error prints to the logger at "Error" log level.

func (*Logger) Errorf

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

Errorf prints formatted output to the logger at "Error" log level.

func (*Logger) Fatal

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

Fatal prints to the logger at "Critical" log level and finishes the app.

func (*Logger) Fatalf

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

Fatalf prints formatted output to the logger at "Critical" log level and finishes the app.

func (*Logger) Info

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

Info prints to the logger at "Info" log level.

func (*Logger) Infof

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

Infof prints formatted output to the logger at "Info" log level.

func (*Logger) Level added in v1.1.1

func (l *Logger) Level() Level

Level returns the current value of the log level.

func (*Logger) Output

func (l *Logger) Output(level Level, s string) error

Output writes the output for a logging event.

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

Panic prints to the logger at "Critical" log level and panics.

func (*Logger) Panicf

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

Panicf prints formatted output to the logger at "Critical" log level and panics.

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

Print prints to the logger at "Info" log level. It is added for backward compatibility with the standard logger.

func (*Logger) Printf

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

Printf prints formatted output to the logger at "Info" log level. It is added for backward compatibility with the standard logger.

func (*Logger) SetLevel

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

SetLevel changes the log level to the provided.

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOutput sets the output destination for the logger.

func (*Logger) Warn

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

Warn prints to the logger at "Warning" log level.

func (*Logger) Warnf

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

Warnf prints formatted output to the logger at "Warning" log level.

Jump to

Keyboard shortcuts

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