factorlog

package module
v0.0.0-...-6ea75a1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 11 Imported by: 166

README

FactorLog

FactorLog is a fast logging infrastructure for Go that provides numerous logging functions for whatever your style may be. It could easily be a replacement for Go's log in the standard library (though it doesn't support functions such as SetFlags()).

It has a modular formatter interface, and even have a GELF and glog formatter in the contrib.

Documentation here: http://godoc.org/github.com/kdar/factorlog

factorlog

Features

  • Various log severities: TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, STACK, FATAL, PANIC
  • Configurable, formattable logger. Check factorlog-contrib for examples.
  • Modular formatter. Care about speed? Use GlogFormatter or roll your own.
  • Designed with speed in mind (it's really fast).
  • Many logging functions to fit your style of logging. (Trace, Tracef, Traceln, etc...)
  • Supports colors.
  • Settable verbosity like glog.
  • Filter by severity.
  • Used in a production system, so it will get some love.

Motivation

There are many good logging libraries out there but none of them worked the way I wanted them to. For example, some libraries have an API like log.Info(), but behind the scenes it's using fmt.Sprintf. What this means is I couldn't do things like log.Info(err). I would instead have to do log.Info("%s", err.Error()). This kept biting me as I was coding. In FactorLog, log.Info behaves exactly like fmt.Sprint. log.Infof uses fmt.Sprintf and log.Infoln uses fmt.Sprintln.

I really like glog, but I don't like that it takes over your command line arguments. I may implement more of its features into FactorLog.

I also didn't want a library that read options from a configuration file. You could easily handle that yourself if you wanted to. FactorLog doesn't include any code for logging to different backends (files, syslog, etc...). The reason for this is I was structuring this after http://12factor.net/. There are many programs out there that can parse your log output from stdout/stderr and redirect it to the appropriate place. However, FactorLog doesn't prevent you from writing this code yourself. I think it would be better if there was a third party library that did backend work itself. Then every logging library could benefit from it.

Examples

You can use the API provided by the package itself just like Go's log does:

package main

import (
  log "github.com/kdar/factorlog"
)

func main() {
  log.Println("Hello there!")
}

Or, you can make your own log from FactorLog:

package main

import (
  "github.com/kdar/factorlog"
  "os"
)

func main() {
  log := factorlog.New(os.Stdout, factorlog.NewStdFormatter("%{Date} %{Time} %{File}:%{Line} %{Message}"))
  log.Println("Hello there!")
}

Check the examples/ directory for more.

Documentation

http://godoc.org/github.com/kdar/factorlog

API Stability

I'm using this in software that is rapidly changing, so I haven't stabilized the API of this just yet.

Documentation

Overview

FactorLog is a logging infrastructure for Go that provides numerous logging functions for whatever your style may be. It could easily be a replacement for Go's log in the standard library (though it doesn't support functions such as `SetFlags()`).

Basic usage:

import log "github.com/kdar/factorlog"
log.Print("Hello there!")

Setting your own format:

import os
import "github.com/kdar/factorlog"
log := factorlog.New(os.Stdout, factorlog.NewStdFormatter("%{Date} %{Time} %{File}:%{Line} %{Message}"))
log.Print("Hello there!")

Setting the verbosity and testing against it:

import os
import "github.com/kdar/factorlog"
log := factorlog.New(os.Stdout, factorlog.NewStdFormatter("%{Date} %{Time} %{File}:%{Line} %{Message}"))
log.SetVerbosity(2)
log.V(1).Print("Will print")
log.V(3).Print("Will not print")

If you care about performance, you can test for verbosity this way:

if log.IsV(1) {
  log.Print("Hello there!")
}

For more usage examples, check the examples/ directory.

Format verbs:

%{SEVERITY} - TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, STACK, FATAL, PANIC
%{Severity} - Trace, Debug, Info, Warn, Error, Critical, Stack, Fatal, Panic
%{severity} - trace, debug, info, warn, error, critical, stack, fatal, panic
%{SEV} - TRAC, DEBG, INFO, WARN, EROR, CRIT, STAK, FATL, PANC
%{Sev} - Trac, Debg, Info, Warn, Eror, Crit, Stak, Fatl, Panc
%{sev} - trac, debg, info, warn, eror, crit, stak, fatl, panc
%{S} - T, D, I, W, E, C, S, F, P
%{s} - t, d, i, w, e, c, s, f, p
%{Date} - Shorthand for 2006-01-02
%{Time} - Shorthand for 15:04:05
%{Time "<fmt>"} - Specify a format (read time.Format for details).
                  Optimized formats: 2006/01/02, 15:04:05.000, 15:04:05.000000, 15:04:05.000000000
%{Unix} - Returns the number of seconds elapsed since January 1, 1970 UTC.
%{UnixNano} - Returns the number of nanoseconds elapsed since January 1, 1970 UTC.
%{Pid} - Process ID of current process.
%{FullFile} - Full source file path (e.g. /dev/project/file.go).
%{File} - The source file name (e.g. file.go).
%{ShortFile} - The short source file name (file without .go).
%{Line} - The source line number.
%{FullFunction} - The full source function including path. (e.g. /dev/project.(*Type).Function)
%{PkgFunction} - The source package and function (e.g. project.(*Type).Function)
%{Function} - The source function name (e.g. (*Type).Function)
%{Color "<fmt>"} - Specify a color (uses https://github.com/mgutz/ansi)
%{Color "<fmt>" "<severity>"} - Specify a color for a given severity (e.g. %{Color "red" "ERROR"})
%{Message} - The message.
%{SafeMessage} - Safe message. It will escape any character below ASCII 32. This helps prevent
                 attacks like using 0x08 to backspace log entries.

Example colors (see https://github.com/mgutz/ansi for more examples):

Added to mgutz/ansi:
  %{Color "reset"}          - reset colors
Supported by mgutz/ansi
  %{Color "red"}            - red
  %{Color "red+b"}          - red bold
  %{Color "red+B"}          - red blinking
  %{Color "red+u"}          - red underline
  %{Color "red+bh"}         - red bold bright
  %{Color "red:white"}      - red on white
  %{Color "red+b:white+h"}  - red bold on white bright
  %{Color "red+B:white+h"}  - red blink on white bright

All logging functions ending in "ln" are merely convenience functions and won't actually output another newline. This allows the formatters to handle a newline however they like (e.g. if you wanted to make a formatter that would output a streamed format without newlines).

Index

Constants

This section is empty.

Variables

View Source
var CapSeverityStrings = [...]string{
	"None",
	"Trace",
	"Debug",
	"Info",
	"Warn",
	"Error",
	"Critical",
	"Stack",
	"Fatal",
	"Panic",
}
View Source
var CapShortSeverityStrings = [...]string{
	"None",
	"Trac",
	"Debg",
	"Info",
	"Warn",
	"Eror",
	"Crit",
	"Stak",
	"Fatl",
	"Panc",
}
View Source
var LcSeverityStrings = [...]string{
	"none",
	"trace",
	"debug",
	"info",
	"warn",
	"error",
	"critical",
	"stack",
	"fatal",
	"panic",
}
View Source
var LcShortSeverityStrings = [...]string{
	"none",
	"trac",
	"debg",
	"info",
	"warn",
	"eror",
	"crit",
	"stak",
	"fatl",
	"panc",
}
View Source
var LcShortestSeverityStrings = [...]string{
	"n",
	"t",
	"d",
	"i",
	"w",
	"e",
	"c",
	"s",
	"f",
	"p",
}
View Source
var UcSeverityStrings = [...]string{
	"NONE",
	"TRACE",
	"DEBUG",
	"INFO",
	"WARN",
	"ERROR",
	"CRITICAL",
	"STACK",
	"FATAL",
	"PANIC",
}
View Source
var UcShortSeverityStrings = [...]string{
	"NONE",
	"TRAC",
	"DEBG",
	"INFO",
	"WARN",
	"EROR",
	"CRIT",
	"STAK",
	"FATL",
	"PANC",
}
View Source
var UcShortestSeverityStrings = [...]string{
	"",
	"T",
	"D",
	"I",
	"W",
	"E",
	"C",
	"S",
	"F",
	"P",
}

Functions

func Critical

func Critical(v ...interface{})

func Criticalf

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

func Criticalln

func Criticalln(v ...interface{})

func Debug

func Debug(v ...interface{})

func Debugf

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

func Debugln

func Debugln(v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

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

func Errorln

func Errorln(v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(v ...interface{})

func GetStack

func GetStack(calldepth int) []byte

func I64toa

func I64toa(buf *[]byte, i int, d int64) int

I64toa is the same as itoa but for 64bit integers

func Info

func Info(v ...interface{})

func Infof

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

func Infoln

func Infoln(v ...interface{})

func IsV

func IsV(level Level) bool

func Itoa

func Itoa(buf *[]byte, i, d int) int

itoa converts an integer d to its ascii representation i is the deintation index in buf algorithm from https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920

func Log

func Log(sev Severity, v ...interface{})

func NDigits

func NDigits(buf *[]byte, n, i, d int)

nDigits converts an integer d to its ascii representation n is how many digits to use i is the destination index in buf

func Panic

func Panic(v ...interface{})

func Panicf

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

func Panicln

func Panicln(v ...interface{})

func Print

func Print(v ...interface{})

func Printf

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

func Println

func Println(v ...interface{})

func SetFormatter

func SetFormatter(f Formatter)

SetFormatter sets the formatter for the standard logger.

func SetMinMaxSeverity

func SetMinMaxSeverity(min Severity, max Severity)

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output destination for the standard logger.

func SetSeverities

func SetSeverities(sev Severity)

func SetVerbosity

func SetVerbosity(level Level)

func SeverityToIndex

func SeverityToIndex(sev Severity) int

We use this function to convert a severity to an index that we can then use to index variables like UcSeverityStrings. Why don't we use maps? This is almost 3x faster.

func Stack

func Stack(v ...interface{})

func Stackf

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

func Stackln

func Stackln(v ...interface{})

func Trace

func Trace(v ...interface{})

func Tracef

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

func Traceln

func Traceln(v ...interface{})

func TwoDigits

func TwoDigits(buf *[]byte, i, d int)

twoDigits converts an integer d to its ascii representation i is the destination index in buf

func Ui64toa

func Ui64toa(buf *[]byte, i int, d uint64) int

Ui64toa is the same as itoa but for 64bit unsigned integers

func Warn

func Warn(v ...interface{})

func Warnf

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

func Warnln

func Warnln(v ...interface{})

Types

type FactorLog

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

FactorLog is a logging object that outputs data to an io.Writer. Each write is threadsafe.

func New

func New(out io.Writer, formatter Formatter) *FactorLog

New creates a FactorLog with the given output and format.

func (*FactorLog) Critical

func (l *FactorLog) Critical(v ...interface{})

Critical is equivalent to Print with severity CRITICAL.

func (*FactorLog) Criticalf

func (l *FactorLog) Criticalf(format string, v ...interface{})

Criticalf is equivalent to Printf with severity CRITICAL.

func (*FactorLog) Criticalln

func (l *FactorLog) Criticalln(v ...interface{})

Criticalln is equivalent to Println with severity CRITICAL.

func (*FactorLog) Debug

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

Debug is equivalent to Print with severity DEBUG.

func (*FactorLog) Debugf

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

Debugf is equivalent to Printf with severity DEBUG.

func (*FactorLog) Debugln

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

Debugln is equivalent to Println with severity DEBUG.

func (*FactorLog) Error

func (l *FactorLog) Error(v ...interface{})

Error is equivalent to Print with severity ERROR.

func (*FactorLog) Errorf

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

Errorf is equivalent to Printf with severity ERROR.

func (*FactorLog) Errorln

func (l *FactorLog) Errorln(v ...interface{})

Errorln is equivalent to Println with severity ERROR.

func (*FactorLog) Fatal

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

Fatal is equivalent to Print() followed by a call to os.Exit(1).

func (*FactorLog) Fatalf

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

Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

func (*FactorLog) Fatalln

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

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

func (*FactorLog) Info

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

Info is equivalent to Print with severity INFO.

func (*FactorLog) Infof

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

Infof is equivalent to Printf with severity INFO.

func (*FactorLog) Infoln

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

Infoln is equivalent to Println with severity INFO.

func (*FactorLog) IsV

func (l *FactorLog) IsV(level Level) bool

IsV tests whether the verbosity is of a certain level. Returns a bool. Example:

if log.IsV(2) {
  log.Info("some info")
}

func (*FactorLog) Log

func (l *FactorLog) Log(sev Severity, v ...interface{})

Log calls l.output to print to the logger. Uses fmt.Sprint.

func (*FactorLog) Output

func (l *FactorLog) Output(sev Severity, calldepth int, v ...interface{}) error

Output will write to the writer with the given severity, calldepth, and string. calldepth is only used if the format requires a call to runtime.Caller.

func (*FactorLog) Panic

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

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

func (*FactorLog) Panicf

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

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

func (*FactorLog) Panicln

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

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

func (*FactorLog) Print

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

Print calls l.output to print to the logger. Uses fmt.Sprint.

func (*FactorLog) Printf

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

Print calls l.output to print to the logger. Uses fmt.Sprintf.

func (*FactorLog) Println

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

Println calls l.output to print to the logger. Uses fmt.Sprint. This is more of a convenience function. If you really want to output an extra newline at the end, just append \n.

func (*FactorLog) SetFormatter

func (l *FactorLog) SetFormatter(f Formatter)

SetFormatter sets the formatter for this logger.

func (*FactorLog) SetMinMaxSeverity

func (l *FactorLog) SetMinMaxSeverity(min Severity, max Severity)

SetMinMaxSeverity sets the minimum and maximum severities this log will output for. Example:

l.SetMinMaxSeverity(INFO, ERROR)

func (*FactorLog) SetOutput

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

SetOutput sets the output destination for this logger.

func (*FactorLog) SetSeverities

func (l *FactorLog) SetSeverities(sev Severity)

SetSeverities sets which severities this log will output for. Example:

l.SetSeverities(INFO|DEBUG)

func (*FactorLog) SetVerbosity

func (l *FactorLog) SetVerbosity(level Level)

Sets the verbosity level of this log. Use IsV() or V() to utilize verbosity.

func (*FactorLog) Stack

func (l *FactorLog) Stack(v ...interface{})

Stack is equivalent to Print() followed by printing a stack trace to the configured writer.

func (*FactorLog) Stackf

func (l *FactorLog) Stackf(format string, v ...interface{})

Stackf is equivalent to Printf() followed by printing a stack trace to the configured writer.

func (*FactorLog) Stackln

func (l *FactorLog) Stackln(v ...interface{})

Stackln is equivalent to Println() followed by printing a stack trace to the configured writer.

func (*FactorLog) Trace

func (l *FactorLog) Trace(v ...interface{})

Trace is equivalent to Print with severity TRACE.

func (*FactorLog) Tracef

func (l *FactorLog) Tracef(format string, v ...interface{})

Tracef is equivalent to Printf with severity TRACE.

func (*FactorLog) Traceln

func (l *FactorLog) Traceln(v ...interface{})

Traceln is equivalent to Println with severity TRACE.

func (*FactorLog) V

func (l *FactorLog) V(level Level) Verbose

V tests whether the verbosity is of a certain level, and returns a Verbose object that allows you to chain calls. This is a convenience function and should be avoided if you care about raw performance (use IsV() instead). Example:

log.V(2).Info("some info")

func (*FactorLog) Warn

func (l *FactorLog) Warn(v ...interface{})

Warn is equivalent to Print with severity WARN.

func (*FactorLog) Warnf

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

Warnf is equivalent to Printf with severity WARN.

func (*FactorLog) Warnln

func (l *FactorLog) Warnln(v ...interface{})

Warnln is equivalent to Println with severity WARN.

type Formatter

type Formatter interface {
	// Formats LogRecord and returns the []byte that will
	// be written by the log. This is not inherently thread
	// safe but FactorLog uses a mutex before calling this.
	Format(context LogContext) []byte

	// Returns true if we should call runtime.Caller because
	// we have a format that requires it. We do this because
	// it is expensive.
	ShouldRuntimeCaller() bool
}

Interface to format anything

type Level

type Level int32

Level represents the level of verbosity.

type LogContext

type LogContext struct {
	Time     time.Time
	Severity Severity
	File     string
	Line     int
	Function string
	Pid      int
	Format   *string
	Args     []interface{}
}

Structure used to hold the data used for formatting

type Logger

type Logger interface {
	Output(sev Severity, calldepth int, v ...interface{}) error
	Trace(v ...interface{})
	Tracef(format string, v ...interface{})
	Traceln(v ...interface{})
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Debugln(v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Infoln(v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Warnln(v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Errorln(v ...interface{})
	Critical(v ...interface{})
	Criticalf(format string, v ...interface{})
	Criticalln(v ...interface{})
	Stack(v ...interface{})
	Stackf(format string, v ...interface{})
	Stackln(v ...interface{})
	Log(sev Severity, v ...interface{})

	//Log verbosity
	V(level Level) Verbose
	SetVerbosity(level Level)
	IsV(level Level) bool

	// golang's log interface
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
}

type NullLogger

type NullLogger struct{}

Creates a logger that outputs to nothing

func (NullLogger) Critical

func (NullLogger) Critical(v ...interface{})

func (NullLogger) Criticalf

func (NullLogger) Criticalf(format string, v ...interface{})

func (NullLogger) Criticalln

func (NullLogger) Criticalln(v ...interface{})

func (NullLogger) Debug

func (NullLogger) Debug(v ...interface{})

func (NullLogger) Debugf

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

func (NullLogger) Debugln

func (NullLogger) Debugln(v ...interface{})

func (NullLogger) Error

func (NullLogger) Error(v ...interface{})

func (NullLogger) Errorf

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

func (NullLogger) Errorln

func (NullLogger) Errorln(v ...interface{})

func (NullLogger) Fatal

func (NullLogger) Fatal(v ...interface{})

func (NullLogger) Fatalf

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

func (NullLogger) Fatalln

func (NullLogger) Fatalln(v ...interface{})

func (NullLogger) Info

func (NullLogger) Info(v ...interface{})

func (NullLogger) Infof

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

func (NullLogger) Infoln

func (NullLogger) Infoln(v ...interface{})

func (NullLogger) IsV

func (NullLogger) IsV(level Level) bool

func (NullLogger) Log

func (NullLogger) Log(sev Severity, v ...interface{})

func (NullLogger) Output

func (NullLogger) Output(sev Severity, calldepth int, v ...interface{}) error

func (NullLogger) Panic

func (NullLogger) Panic(v ...interface{})

func (NullLogger) Panicf

func (NullLogger) Panicf(format string, v ...interface{})

func (NullLogger) Panicln

func (NullLogger) Panicln(v ...interface{})

func (NullLogger) Print

func (NullLogger) Print(v ...interface{})

func (NullLogger) Printf

func (NullLogger) Printf(format string, v ...interface{})

func (NullLogger) Println

func (NullLogger) Println(v ...interface{})

func (NullLogger) SetVerbosity

func (NullLogger) SetVerbosity(level Level)

func (NullLogger) Stack

func (NullLogger) Stack(v ...interface{})

func (NullLogger) Stackf

func (NullLogger) Stackf(format string, v ...interface{})

func (NullLogger) Stackln

func (NullLogger) Stackln(v ...interface{})

func (NullLogger) Trace

func (NullLogger) Trace(v ...interface{})

func (NullLogger) Tracef

func (NullLogger) Tracef(format string, v ...interface{})

func (NullLogger) Traceln

func (NullLogger) Traceln(v ...interface{})

func (NullLogger) V

func (NullLogger) V(level Level) Verbose

func (NullLogger) Warn

func (NullLogger) Warn(v ...interface{})

func (NullLogger) Warnf

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

func (NullLogger) Warnln

func (NullLogger) Warnln(v ...interface{})

type Severity

type Severity int32

Severity represents the severity of the log.

const (
	NONE Severity = 1 << iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	CRITICAL
	STACK
	FATAL
	PANIC
)

func StringToSeverity

func StringToSeverity(s string) Severity

Convert an uppercase string to a severity.

type StdFormatter

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

func NewStdFormatter

func NewStdFormatter(frmt string) *StdFormatter

Available verbs:

%{SEVERITY} - TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, STACK, FATAL, PANIC
%{Severity} - Trace, Debug, Info, Warn, Error, Critical, Stack, Fatal, Panic
%{severity} - trace, debug, info, warn, error, critical, stack, fatal, panic
%{SEV} - TRAC, DEBG, INFO, WARN, EROR, CRIT, STAK, FATL, PANC
%{Sev} - Trac, Debg, Info, Warn, Eror, Crit, Stak, Fatl, Panc
%{sev} - trac, debg, info, warn, eror, crit, stak, fatl, panc
%{S} - T, D, I, W, E, C, S, F, P
%{s} - t, d, i, w, e, c, s, f, p
%{Date} - Shorthand for 2006-01-02
%{Time} - Shorthand for 15:04:05
%{Time "<fmt>"} - Specify a format (read time.Format for details).
                  Optimized formats: 2006/01/02, 15:04:05.000, 15:04:05.000000, 15:04:05.000000000
%{Unix} - Returns the number of seconds elapsed since January 1, 1970 UTC.
%{UnixNano} - Returns the number of nanoseconds elapsed since January 1, 1970 UTC.
%{FullFile} - Full source file path (e.g. /dev/project/file.go).
%{File} - The source file name (e.g. file.go).
%{ShortFile} - The short source file name (file without .go).
%{Line} - The source line number.
%{FullFunction} - The full source function including path. (e.g. /dev/project.(*Type).Function)
%{PkgFunction} - The source package and function (e.g. project.(*Type).Function)
%{Function} - The source function name (e.g. (*Type).Function)
%{Color "<fmt>"} - Specify a color (uses https://github.com/mgutz/ansi)
%{Color "<fmt>" "<severity>"} - Specify a color for a given severity (e.g. %{Color "red" "ERROR"})
%{Message} - The message.
%{SafeMessage} - Safe message. It will escape any character below ASCII 32. This helps prevent
                 attacks like using 0x08 to backspace log entries.

func (*StdFormatter) Format

func (f *StdFormatter) Format(context LogContext) []byte

func (*StdFormatter) ShouldRuntimeCaller

func (f *StdFormatter) ShouldRuntimeCaller() bool

type Verbose

type Verbose struct {
	True bool
	// contains filtered or unexported fields
}

Verbose is a structure that enables syntatic sugar when testing for verbosity and calling a log function. See FactorLog.V().

func V

func V(level Level) Verbose

func (Verbose) Critical

func (b Verbose) Critical(v ...interface{})

func (Verbose) Criticalf

func (b Verbose) Criticalf(format string, v ...interface{})

func (Verbose) Criticalln

func (b Verbose) Criticalln(v ...interface{})

func (Verbose) Debug

func (b Verbose) Debug(v ...interface{})

func (Verbose) Debugf

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

func (Verbose) Debugln

func (b Verbose) Debugln(v ...interface{})

func (Verbose) Error

func (b Verbose) Error(v ...interface{})

func (Verbose) Errorf

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

func (Verbose) Errorln

func (b Verbose) Errorln(v ...interface{})

func (Verbose) Fatal

func (b Verbose) Fatal(v ...interface{})

func (Verbose) Fatalf

func (b Verbose) Fatalf(format string, v ...interface{})

func (Verbose) Fatalln

func (b Verbose) Fatalln(v ...interface{})

func (Verbose) Info

func (b Verbose) Info(v ...interface{})

func (Verbose) Infof

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

func (Verbose) Infoln

func (b Verbose) Infoln(v ...interface{})

func (Verbose) IsV

func (b Verbose) IsV(level Level) bool

func (Verbose) Log

func (b Verbose) Log(sev Severity, v ...interface{})

func (Verbose) Output

func (b Verbose) Output(sev Severity, calldepth int, v ...interface{}) error

func (Verbose) Panic

func (b Verbose) Panic(v ...interface{})

func (Verbose) Panicf

func (b Verbose) Panicf(format string, v ...interface{})

func (Verbose) Panicln

func (b Verbose) Panicln(v ...interface{})

func (Verbose) Print

func (b Verbose) Print(v ...interface{})

func (Verbose) Printf

func (b Verbose) Printf(format string, v ...interface{})

func (Verbose) Println

func (b Verbose) Println(v ...interface{})

func (Verbose) SetVerbosity

func (b Verbose) SetVerbosity(level Level)

func (Verbose) Stack

func (b Verbose) Stack(v ...interface{})

func (Verbose) Stackf

func (b Verbose) Stackf(format string, v ...interface{})

func (Verbose) Stackln

func (b Verbose) Stackln(v ...interface{})

func (Verbose) Trace

func (b Verbose) Trace(v ...interface{})

func (Verbose) Tracef

func (b Verbose) Tracef(format string, v ...interface{})

func (Verbose) Traceln

func (b Verbose) Traceln(v ...interface{})

func (Verbose) V

func (b Verbose) V(level Level) Verbose

func (Verbose) Warn

func (b Verbose) Warn(v ...interface{})

func (Verbose) Warnf

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

func (Verbose) Warnln

func (b Verbose) Warnln(v ...interface{})

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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