jot

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jot provides simple asynchronous logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug logs a debugging message. Arguments are handled in the manner of fmt.Print.

func Debugf

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

Debugf logs a debugging message. Arguments are handled in the manner of fmt.Printf.

func Error

func Error(v ...interface{})

Error logs an error message. Arguments are handled in the manner of fmt.Print.

func Errorf

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

Errorf logs an error message. Arguments are handled in the manner of fmt.Printf.

func Fatal

func Fatal(status int, v ...interface{})

Fatal logs a fatal error message. Arguments other than the status are handled in the manner of fmt.Print.

func FatalIfErr

func FatalIfErr(err error)

FatalIfErr calls 'Fatal(1, err)' if 'err' is not nil.

func Fatalf

func Fatalf(status int, format string, v ...interface{})

Fatalf logs a fatal error message. Arguments other than the status are handled in the manner of fmt.Printf.

func Flush

func Flush()

Flush waits for all current log entries to be written before returning.

func Info

func Info(v ...interface{})

Info logs an informational message. Arguments are handled in the manner of fmt.Print.

func Infof

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

Infof logs an informational message. Arguments are handled in the manner of fmt.Printf.

func SetMinimumLevel

func SetMinimumLevel(level Level)

SetMinimumLevel sets the minimum log level that will be output. Default is DEBUG.

func SetWriter

func SetWriter(w io.Writer)

SetWriter sets the io.Writer to use when writing log messages. Default is os.Stderr.

func Time

func Time(v ...interface{}) logadapter.Timing

Time starts timing an event and logs an informational message. Arguments are handled in the manner of fmt.Print.

func Timef

func Timef(format string, v ...interface{}) logadapter.Timing

Timef starts timing an event and logs an informational message. Arguments are handled in the manner of fmt.Printf.

func Warn

func Warn(v ...interface{})

Warn logs a warning message. Arguments are handled in the manner of fmt.Print.

func Warnf

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

Warnf logs a warning message. Arguments are handled in the manner of fmt.Printf.

Types

type Level

type Level int

Level holds a log level.

const (
	DEBUG Level = iota
	INFO
	WARN
	ERROR
	FATAL
)

Log levels

type Logger

type Logger struct {
}

Logger wraps the various jot function calls into a struct that can be passed around, typically for the sake of satisfying one or more logging interfaces.

func (*Logger) Debug

func (lgr *Logger) Debug(v ...interface{})

Debug logs a debug message. Arguments are handled in the manner of fmt.Print.

func (*Logger) Debugf

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

Debugf logs a debug message. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Error

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

Error logs an error message. Arguments are handled in the manner of fmt.Print.

func (*Logger) Errorf

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

Errorf logs an error message. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Fatal

func (lgr *Logger) Fatal(status int, v ...interface{})

Fatal logs a fatal error message. Arguments other than the status are handled in the manner of fmt.Print.

func (*Logger) Fatalf

func (lgr *Logger) Fatalf(status int, format string, v ...interface{})

Fatalf logs a fatal error message. Arguments other than the status are handled in the manner of fmt.Printf.

func (*Logger) Flush

func (lgr *Logger) Flush()

Flush waits for all current log entries to be written before returning.

func (*Logger) Info

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

Info logs an informational message. Arguments are handled in the manner of fmt.Print.

func (*Logger) Infof

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

Infof logs an informational message. Arguments are handled in the manner of fmt.Printf.

func (*Logger) SetMinimumLevel

func (lgr *Logger) SetMinimumLevel(level Level)

SetMinimumLevel sets the minimum log level that will be output. Default is DEBUG.

func (*Logger) SetWriter

func (lgr *Logger) SetWriter(w io.Writer)

SetWriter sets the io.Writer to use when writing log messages. Default is os.Stderr.

func (*Logger) Time

func (lgr *Logger) Time(v ...interface{}) logadapter.Timing

Time starts timing an event and logs an informational message. Arguments are handled in the manner of fmt.Print.

func (*Logger) Timef

func (lgr *Logger) Timef(format string, v ...interface{}) logadapter.Timing

Timef starts timing an event and logs an informational message. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Warn

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

Warn logs a warning message. Arguments are handled in the manner of fmt.Print.

func (*Logger) Warnf

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

Warnf logs a warning message. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Write

func (lgr *Logger) Write(data []byte) (int, error)

Writer logs the data as an error after casting it to a string.

type LoggerWriter

type LoggerWriter struct {
	Filter func(v ...interface{})
}

LoggerWriter provides a bridge between the standard log.Logger and the jot package. You can use it like this:

log.New(&jot.LoggerWriter{}, "", 0)

This will send all output for this logger to the jot.Error() call.

You can also set the Filter function to direct the output to a particular jot logging method:

log.New(&jot.LoggerWriter{Filter: jot.Info}), "", 0)

func (*LoggerWriter) Write

func (w *LoggerWriter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface required by log.Logger.

Jump to

Keyboard shortcuts

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