log

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

package log defines strict logger types, which is referenced from https://dave.cheney.net/2015/11/05/lets-talk-about-logging.

Index

Constants

View Source
const (
	// These are specifies logging level.
	// InfoLevel outputs only calling Info*.
	// DebugLevel outputs all of outputting call, Info* and Debug*.
	InfoLevel  = iota // output only Info*
	DebugLevel        // output all, Info* and Debug*
)
View Source
const (
	// These flags are same as log package's.
	Ldate         = log.Ldate         // the date in the local time zone: 2009/01/23
	Ltime         = log.Ltime         // the time in the local time zone: 01:23:23
	Lmicroseconds = log.Lmicroseconds // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile     = log.Llongfile     // full file name and line number: /a/b/c/d.go:23
	Lshortfile    = log.Lshortfile    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC          = log.LUTC          // if Ldate or Ltime is set, use UTC rather than the local time zone
	LstdFlags     = log.LstdFlags     // initial values for the standard logger
)
View Source
const DebugPrefix = "DEBUG: "

DebugPrefix is 2nd prefix of outputting text when call Debug*. The most left prefix is which is used for SetPrefix or New(.., prefix, ...). So DebugPrefix places right by the most left prefix and left by the outputting text.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugf

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

func Debugln

func Debugln(v ...interface{})

func Flags

func Flags() int

func Info

func Info(v ...interface{})

func Infof

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

func Infoln

func Infoln(v ...interface{})

func Level

func Level() int

return current logging level for default logger.

func Prefix

func Prefix() string

func SetFlags

func SetFlags(flag int)

func SetLevel

func SetLevel(level int)

set logging level to default logger.

func SetOutput

func SetOutput(w io.Writer)

func SetPrefix

func SetPrefix(prefix string)

Types

type Logger

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

func New

func New(out io.Writer, prefix string, flag int) *Logger

construct new Logger. default output level is InfoLevel.

func (*Logger) Debug

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

func (*Logger) Debugf

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

func (*Logger) Debugln

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

func (*Logger) Flags

func (l *Logger) Flags() int

same as standard package's log

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) Infoln

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

func (*Logger) Level

func (l *Logger) Level() int

return current logging level.

func (*Logger) Prefix

func (l *Logger) Prefix() string

same as standard package's log

func (*Logger) SetFlags

func (l *Logger) SetFlags(flag int)

same as standard package's log

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

set logging level.

func (*Logger) SetOutput

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

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

same as standard package's log

type SilentWriter

type SilentWriter struct{}

SilentWriter implements io.Writer. it writes no content and return no error so that any writing is ignored.

func (SilentWriter) Write

func (SilentWriter) Write([]byte) (int, error)

Jump to

Keyboard shortcuts

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