log

package module
v0.0.0-...-2b13006 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 13 Imported by: 8

Documentation

Index

Constants

View Source
const (
	OutputKey           = "log_output"
	FilenameKey         = "log_filename"
	LevelKey            = "log_level"
	ForceColorsKey      = "log_color"
	DisableColorsKey    = "log_nocolor"
	DisableTimestampKey = "log_notimestamp"
	ShortTimestampKey   = "log_shorttimestamp"
	TimestampFormatKey  = "log_formattimestamp"
)

OutputKey is the viper variable used to define the output FilenameKey is the viper variable used to define log filename LevelKey is the viper variable used to define log level key ForceColorsKey is the viper variable used to define if color should be forced DisableColorsKey is the viper variable used to define if the colors should be disabled DisableTimestampKey is the viper variable used to define if the log timestamp should be disabled ShortTimestampKey is the viper variable used to define the log timestamp short format TimestampFormatKey is the viper variable used to define the log timestamp format

View Source
const (
	PrefixField = "prefix"
)

PrefixField is the viper variable to set and get the prefix to use in the text formatter

Variables

This section is empty.

Functions

func GetPrefix

func GetPrefix() string

GetPrefix return the prefix

func NewEntryWithPrefix

func NewEntryWithPrefix(prefix string) *logrus.Entry

NewEntryWithPrefix creates a new logrus.Entry with a prefix.

func Prefix

func Prefix(prefix string) *logrus.Entry

Prefix is an alias for NewEntryWithPrefix. It's used to print a message with a different prefix

func SetPrefix

func SetPrefix(prefix string)

SetPrefix sets the output prefix for the standard logger

Types

type Logger

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

Logger encapsulate logrus.Logger and add the prefix. It also implements the interface cli.Ui from github.com/mitchellh/cli to print logs using the text formatter

func New

func New(v *viper.Viper) *Logger

New creates a new Logger configured from an existing viper instance

func NewDefault

func NewDefault() *Logger

NewDefault creates a new Logger configured with defaults values or global viper values if they are defined.

func StdLogger

func StdLogger() *Logger

StdLogger return the standar logger

func (*Logger) Ask

func (logger *Logger) Ask(query string) (string, error)

Ask asks the user for input using the given query. This UI do not ask questions so it implements nothing.

func (*Logger) AskSecret

func (logger *Logger) AskSecret(query string) (string, error)

AskSecret asks the user for input using the given query, but does not echo the keystrokes to the terminal. This UI do not ask questions so it implements nothing.

func (*Logger) Copy

func (logger *Logger) Copy() *Logger

Copy makes a deep copy of this logger

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

Debug redeclares the logrus method with the same name to use the prefix set

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, args ...interface{})

Debugf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Debugln

func (logger *Logger) Debugln(args ...interface{})

Debugln redeclares the logrus method with the same name to use the prefix set

func (*Logger) Error

func (logger *Logger) Error(message string)

Error is used for any error messages that might appear on standard error.

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, args ...interface{})

Errorf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Errorln

func (logger *Logger) Errorln(args ...interface{})

Errorln redeclares the logrus method with the same name to use the prefix set

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

Fatal redeclares the logrus method with the same name to use the prefix set

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, args ...interface{})

Fatalf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Fatalln

func (logger *Logger) Fatalln(args ...interface{})

Fatalln redeclares the logrus method with the same name to use the prefix set

func (*Logger) GetPrefix

func (logger *Logger) GetPrefix() string

GetPrefix return the prefix

func (*Logger) Info

func (logger *Logger) Info(message string)

Info is called for information output.

func (*Logger) Infof

func (logger *Logger) Infof(format string, args ...interface{})

Infof redeclares the logrus method with the same name to use the prefix set

func (*Logger) Infoln

func (logger *Logger) Infoln(args ...interface{})

Infoln redeclares the logrus method with the same name to use the prefix set

func (*Logger) NewEntryWithPrefix

func (logger *Logger) NewEntryWithPrefix(prefix string) *logrus.Entry

NewEntryWithPrefix creates a new logrus.Entry with a prefix.

func (*Logger) Output

func (logger *Logger) Output(message string)

Output is called for normal standard output.

func (*Logger) Panic

func (logger *Logger) Panic(args ...interface{})

Panic redeclares the logrus method with the same name to use the prefix set

func (*Logger) Panicf

func (logger *Logger) Panicf(format string, args ...interface{})

Panicf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Panicln

func (logger *Logger) Panicln(args ...interface{})

Panicln redeclares the logrus method with the same name to use the prefix set

func (*Logger) Prefix

func (logger *Logger) Prefix(prefix string) *logrus.Entry

Prefix is an alias for NewEntryWithPrefix. It's used to print a message with a prefix

func (*Logger) Print

func (logger *Logger) Print(args ...interface{})

Print redeclares the logrus method with the same name to use the prefix set

func (*Logger) Printf

func (logger *Logger) Printf(format string, args ...interface{})

Printf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Println

func (logger *Logger) Println(args ...interface{})

Println redeclares the logrus method with the same name to use the prefix set

func (*Logger) SetPrefix

func (logger *Logger) SetPrefix(prefix string)

SetPrefix sets the output prefix for the logger.

func (*Logger) Warn

func (logger *Logger) Warn(message string)

Warn is used for any warning messages that might appear on standard error.

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, args ...interface{})

Warnf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Warning

func (logger *Logger) Warning(args ...interface{})

Warning redeclares the logrus method with the same name to use the prefix set

func (*Logger) Warningf

func (logger *Logger) Warningf(format string, args ...interface{})

Warningf redeclares the logrus method with the same name to use the prefix set

func (*Logger) Warningln

func (logger *Logger) Warningln(args ...interface{})

Warningln redeclares the logrus method with the same name to use the prefix set

func (*Logger) Warnln

func (logger *Logger) Warnln(args ...interface{})

Warnln redeclares the logrus method with the same name to use the prefix set

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors.
	ForceColors bool

	// Force disabling colors.
	DisableColors bool

	// Disable timestamp logging. useful when output is redirected to logging
	// system that already adds timestamps.
	DisableTimestamp bool

	// Enable logging just the time passed since beginning of execution instead of
	// the full timestamp when a TTY is attached
	ShortTimestamp bool

	// TimestampFormat to use for display when a full timestamp is printed
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool
}

TextFormatter ...

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format ...

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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