logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int
const (
	InvalidLevel Level = iota - 1
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

type Log

type Log struct {
	LogIface
	// contains filtered or unexported fields
}

Log logging interface

func New

func New(out io.Writer, prefix string, flag int, level Level, eh exit.HandlerIface) *Log

New creates a new Logger. The out variable sets the destination to which log data will be written. The prefix appears at the beginning of each generated log line, or after the log header if the Lmsgprefix flag is provided. The flag argument defines the logging properties.

func (*Log) Debug

func (l *Log) Debug(s string)

Debug debug level message.

func (*Log) Debugf

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

Debugf debug level message.

func (*Log) Error

func (l *Log) Error(s string)

Error error level message.

func (*Log) Errorf

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

Errorf error level message.

func (*Log) Fatal

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

Fatal is equivalent to l.Print() followed by a call to exit.Handler.Exit(1).

func (*Log) Fatalf

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

Fatalf is equivalent to l.Printf() followed by a call to exit.Handler.Exit(1).

func (*Log) Fatalln

func (l *Log) Fatalln(v ...interface{})

Fatalln is equivalent to Println() followed by a call to exit.Handler.Exit(1).

func (*Log) Flags

func (l *Log) Flags() int

Flags returns the output flags for the logger. The flag bits are Ldate, Ltime, and so on.

func (*Log) Output

func (l *Log) Output(calldepth int, s string) error

Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2.

func (*Log) Panic

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

Panic is equivalent to l.Print() followed by a call to panic().

func (*Log) Panicf

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

Panicf is equivalent to l.Printf() followed by a call to panic().

func (*Log) Panicln

func (l *Log) Panicln(v ...interface{})

Panicln is equivalent to l.Println() followed by a call to panic().

func (*Log) Prefix

func (l *Log) Prefix() string

Prefix returns the output prefix for the logger.

func (*Log) Print

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

Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.

func (*Log) Printf

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

Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func (*Log) Println

func (l *Log) Println(v ...interface{})

Println calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Println.

func (*Log) SetFlags

func (l *Log) SetFlags(flag int)

SetFlags sets the output flags for the logger. The flag bits are Ldate, Ltime, and so on.

func (*Log) SetOutput

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

SetOutput sets the output destination for the logger.

func (*Log) SetPrefix

func (l *Log) SetPrefix(prefix string)

SetPrefix sets the output prefix for the logger.

func (*Log) Writer

func (l *Log) Writer() io.Writer

Writer returns the output destination for the logger.

type LogIface

type LogIface interface {
	LoggerIface
	LogLevelIface
}

LogIface

type LogLevelIface

type LogLevelIface interface {
	Error(string)
	Errorf(string, ...interface{})
	Debug(string)
	Debugf(string, ...interface{})
}

LogLevelIface functions run when a level is set

type LoggerIface

type LoggerIface interface {
	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Fatalln(...interface{})
	Flags() int
	Output(int, string) error
	Panic(...interface{})
	Panicf(string, ...interface{})
	Panicln(...interface{})
	Prefix() string
	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})
	SetFlags(int)
	SetOutput(io.Writer)
	SetPrefix(string)
	Writer() io.Writer
}

LoggerIface A interface that matches log.Logger

type OutputIface

type OutputIface interface {
	Debug(string)
	Debugf(string, ...interface{})
	Error(string)
	Errorf(string, ...interface{})
	Output(int, string) error
	Printf(string, ...interface{})
}

OutputIface router interface

type Router

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

Router route log messages to multiple streams

func NewRouter

func NewRouter(route ...OutputIface) *Router

NewRouter create a *Router pointer

func (*Router) Debug

func (r *Router) Debug(s string)

Debug debug level message.

func (*Router) Debugf

func (r *Router) Debugf(format string, v ...interface{})

Debugf debug level message.

func (*Router) Error

func (r *Router) Error(s string)

Error error level message.

func (*Router) Errorf

func (r *Router) Errorf(format string, v ...interface{})

Errorf error level message.

func (*Router) Output

func (r *Router) Output(calldepth int, s string) error

Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2.

func (*Router) Printf

func (r *Router) Printf(format string, v ...interface{})

Printf print error message

Jump to

Keyboard shortcuts

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