fortio: Index | Files

package log

import ""


Package Files



var (

    // LogPrefix is a prefix to include in each log line.
    LogPrefix = flag.String("logprefix", "> ", "Prefix to log lines before logged messages")
    // LogFileAndLine determines if the log lines will contain caller file name and line number.
    LogFileAndLine = flag.Bool("logcaller", true, "Logs filename and line number of callers to log")

func Critf Uses

func Critf(format string, rest ...interface{})

Critf logs if Warning level is on.

func Debugf Uses

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

Debugf logs if Debug level is on.

func Errf Uses

func Errf(format string, rest ...interface{})

Errf logs if Warning level is on.

func Fatalf Uses

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

Fatalf logs if Warning level is on.

func Infof Uses

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

Infof logs if Info level is on.

func Log Uses

func Log(lvl Level) bool

Log returns true if a given level is currently logged.

func LogDebug Uses

func LogDebug() bool

LogDebug shortcut for fortio.Log(fortio.Debug)

func LogVerbose Uses

func LogVerbose() bool

LogVerbose shortcut for fortio.Log(fortio.Verbose)

func LogVf Uses

func LogVf(format string, rest ...interface{})

LogVf logs if Verbose level is on.

func Logf Uses

func Logf(lvl Level, format string, rest ...interface{})

Logf logs with format at the given level. 2 level of calls so it's always same depth for extracting caller file/line

func SetFlags Uses

func SetFlags(f int)

SetFlags forwards flags to the system logger.

func SetOutput Uses

func SetOutput(w io.Writer)

SetOutput sets the output to a different writer (forwards to system logger).

func Warnf Uses

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

Warnf logs if Warning level is on.

type Level Uses

type Level int

Level is the level of logging (0 Debug -> 6 Fatal).

const (
    Debug Level = iota

Log levels. Go can't have variable and function of the same name so we keep medium length (Dbg,Info,Warn,Err,Crit,Fatal) names for the functions.

func GetLogLevel Uses

func GetLogLevel() Level

GetLogLevel returns the currently configured LogLevel.

func LevelByName Uses

func LevelByName(str string) Level

LevelByName returns the LogLevel by its name.

func SetLogLevel Uses

func SetLogLevel(lvl Level) Level

SetLogLevel sets the log level and returns the previous one.

func SetLogLevelQuiet Uses

func SetLogLevelQuiet(lvl Level) Level

SetLogLevelQuiet sets the log level and returns the previous one but does not log the change of level itself.

func (*Level) Set Uses

func (l *Level) Set(str string) error

Set is called by the flags.

func (*Level) String Uses

func (l *Level) String() string

String returns the string representation of the level. Needed for flag Var interface.

func (Level) ToString Uses

func (l Level) ToString() string

ToString returns the string representation of the level. (this can't be the same name as the pointer receiver version)

Package log imports 6 packages (graph) and is imported by 19 packages. Updated 2018-08-28. Refresh now. Tools for package owners.