log

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Logger Proxy API

Consts (in decreasing order of severity):

  • FATAL
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE

Functions:

  • log.SetLogLevel(): Log messages below this level of severity will be ignored. Default Log Level is INFO.

  • log.Fatal(string, vals... interface{}): prevents the program from continuing i.e. can't allocate additional memory

  • log.Error(string, vals... interface{}): non-fatal, but prevents valid execution i.e. can't connect to a database, complete a function call, open file, invalid format

  • log.Warn(string, vals... interface{}): looks unusual, but does not clearly prevent execution

  • log.Info(string, vals... interface{}): Least severe message that a sysadmin would be interested in i.e. server request logs

  • log.Debug(string, vals... interface{}): high level info for a developer. more than what a sysadmin would typically want

  • log.Trace(string, vals... interface{}): excruciating detail.

  • log.SetOutput(io.Writer): Indicates the location for log messages to be written. Default is stdout.

Flags:

These package-level flags are provided to disable expensive code when the code is only needed at
a lower severity than the logger is set at:
    IsError
    IsWarn
    IsInfo
    IsDebug
    IsTrace

example usage:
     if log.IsDebug {
         ...
     }

Output will look like:

"timestamp•LOG_LEVEL•filename.go•linenumber•output"

Documentation

Index

Constants

View Source
const (
	TRACE = Level(iota - 2)
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

Allows the ordering of severity to be checked

Variables

View Source
var (

	// FATAL level is never disabled
	IsError bool
	IsWarn  bool
	IsInfo  bool
	IsDebug bool
	IsTrace bool
)

Functions

func Debug

func Debug(format string, args ...interface{})

func Error

func Error(format string, args ...interface{})

func Fatal

func Fatal(format string, args ...interface{})

Output format should be: "timestamp•LOG_LEVEL•filename.go•linenumber•output"

func Info

func Info(format string, args ...interface{})

func Output

func Output(level string, format string, args ...interface{})

func SetLogLevel

func SetLogLevel(lvl Level)

func SetOutput

func SetOutput(w io.Writer)

func Trace

func Trace(format string, args ...interface{})

func Warn

func Warn(format string, args ...interface{})

Types

type Interface

type Interface interface {
	// These all take args the same as calls to fmt.Printf()
	Fatal(string, ...interface{})
	Error(string, ...interface{})
	Warn(string, ...interface{})
	Info(string, ...interface{})
	Debug(string, ...interface{})
	Trace(string, ...interface{})
	SetOutput(io.Writer)
}

type Level

type Level int

type Standard

type Standard struct{}

func (Standard) Debug

func (_ Standard) Debug(format string, args ...interface{})

func (Standard) Error

func (_ Standard) Error(format string, args ...interface{})

func (Standard) Fatal

func (_ Standard) Fatal(format string, args ...interface{})

func (Standard) Info

func (_ Standard) Info(format string, args ...interface{})

func (Standard) SetOutput

func (_ Standard) SetOutput(w io.Writer)

func (Standard) Trace

func (_ Standard) Trace(format string, args ...interface{})

func (Standard) Warn

func (_ Standard) Warn(format string, args ...interface{})

Jump to

Keyboard shortcuts

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