log

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const AnkorLogTimestamps = "ANKOR_LOG_TIMESTAMPS"

Variables

View Source
var Colors = []string{
	"blue",
	"blue+h",
	"blue+b",
	"green",
	"green+h",
	"green+b",
	"yellow",
	"yellow+h",
	"yellow+b",
	"magenta",
	"magenta+h",
	"magenta+b",
	"cyan",
	"cyan+h",
	"cyan+b",
	"white",
	"white+h",
	"white+b",
}
View Source
var Discard = &DiscardLogger{}

Discard is a logger implementation that just discards every log statement

Functions

func AcquireGlobalSilence

func AcquireGlobalSilence() (string, error)

func OverrideRuntimeErrorHandler

func OverrideRuntimeErrorHandler(discard bool)

OverrideRuntimeErrorHandler overrides the standard runtime error handler that logs to stdout with a file logger that logs all runtime.HandleErrors to errors.log

func PrintTable

func PrintTable(s Logger, header []string, values [][]string)

func PrintTableWithOptions

func PrintTableWithOptions(s Logger, header []string, values [][]string, modify func(table *tablewriter.Table))

PrintTableWithOptions prints a table with header columns and string values

func ReleaseGlobalSilence

func ReleaseGlobalSilence(id string)

func StartFileLogging

func StartFileLogging()

StartFileLogging logs the output of the global logger to the file default.log

func WithNopCloser

func WithNopCloser(writer io.Writer) io.WriteCloser

Types

type DiscardLogger

type DiscardLogger struct{}

DiscardLogger just discards every log statement

func (*DiscardLogger) AddSink

func (d *DiscardLogger) AddSink(log Logger)

func (*DiscardLogger) Children

func (d *DiscardLogger) Children() []Logger

func (*DiscardLogger) Debug

func (d *DiscardLogger) Debug(args ...interface{})

Debug implements logger interface

func (*DiscardLogger) Debugf

func (d *DiscardLogger) Debugf(format string, args ...interface{})

Debugf implements logger interface

func (*DiscardLogger) Done

func (d *DiscardLogger) Done(args ...interface{})

Done implements logger interface

func (*DiscardLogger) Donef

func (d *DiscardLogger) Donef(format string, args ...interface{})

Donef implements logger interface

func (*DiscardLogger) Error

func (d *DiscardLogger) Error(args ...interface{})

Error implements logger interface

func (*DiscardLogger) ErrorStreamOnly

func (d *DiscardLogger) ErrorStreamOnly() Logger

func (*DiscardLogger) Errorf

func (d *DiscardLogger) Errorf(format string, args ...interface{})

Errorf implements logger interface

func (*DiscardLogger) Fail

func (d *DiscardLogger) Fail(args ...interface{})

Fail implements logger interface

func (*DiscardLogger) Failf

func (d *DiscardLogger) Failf(format string, args ...interface{})

Failf implements logger interface

func (*DiscardLogger) Fatal

func (d *DiscardLogger) Fatal(args ...interface{})

Fatal implements logger interface

func (*DiscardLogger) Fatalf

func (d *DiscardLogger) Fatalf(format string, args ...interface{})

Fatalf implements logger interface

func (*DiscardLogger) GetLevel

func (d *DiscardLogger) GetLevel() logrus.Level

GetLevel implements logger interface

func (*DiscardLogger) Info

func (d *DiscardLogger) Info(args ...interface{})

Info implements logger interface

func (*DiscardLogger) Infof

func (d *DiscardLogger) Infof(format string, args ...interface{})

Infof implements logger interface

func (*DiscardLogger) Print

func (d *DiscardLogger) Print(level logrus.Level, args ...interface{})

Print implements logger interface

func (*DiscardLogger) Printf

func (d *DiscardLogger) Printf(level logrus.Level, format string, args ...interface{})

Printf implements logger interface

func (*DiscardLogger) Question

func (d *DiscardLogger) Question(params *survey.QuestionOptions) (string, error)

Question asks a new question

func (*DiscardLogger) SetLevel

func (d *DiscardLogger) SetLevel(level logrus.Level)

SetLevel implements logger interface

func (*DiscardLogger) StartWait

func (d *DiscardLogger) StartWait(message string)

StartWait implements logger interface

func (*DiscardLogger) StopWait

func (d *DiscardLogger) StopWait()

StopWait implements logger interface

func (*DiscardLogger) Warn

func (d *DiscardLogger) Warn(args ...interface{})

Warn implements logger interface

func (*DiscardLogger) Warnf

func (d *DiscardLogger) Warnf(format string, args ...interface{})

Warnf implements logger interface

func (*DiscardLogger) WithLevel

func (d *DiscardLogger) WithLevel(level logrus.Level) Logger

WithLevel implements logger interface

func (*DiscardLogger) WithPrefix

func (d *DiscardLogger) WithPrefix(prefix string) Logger

func (*DiscardLogger) WithPrefixColor

func (d *DiscardLogger) WithPrefixColor(prefix, color string) Logger

func (*DiscardLogger) WithSink

func (d *DiscardLogger) WithSink(log Logger) Logger

func (*DiscardLogger) Write

func (d *DiscardLogger) Write(message []byte) (int, error)

Write implements logger interface

func (*DiscardLogger) WriteString

func (d *DiscardLogger) WriteString(level logrus.Level, message string)

WriteString implements logger interface

func (*DiscardLogger) Writer

func (d *DiscardLogger) Writer(level logrus.Level, raw bool) io.WriteCloser

type Format

type Format int
const (
	TextFormat Format = iota
	TimeFormat Format = iota
	JSONFormat Format = iota
	RawFormat  Format = iota
)

type Line

type Line struct {
	// Time is when this log message occurred
	Time time.Time `json:"time,omitempty"`

	// Message is when the message of the log message
	Message string `json:"message,omitempty"`

	// Level is the log level this message has used
	Level logrus.Level `json:"level,omitempty"`
}

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

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

	Done(args ...interface{})
	Donef(format string, args ...interface{})

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

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

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

	Print(level logrus.Level, args ...interface{})
	Printf(level logrus.Level, format string, args ...interface{})

	Writer(level logrus.Level, raw bool) io.WriteCloser
	WriteString(level logrus.Level, message string)

	Question(params *survey.QuestionOptions) (string, error)

	SetLevel(level logrus.Level)
	GetLevel() logrus.Level

	// WithLevel creates a new logger with the given level
	WithLevel(level logrus.Level) Logger
	ErrorStreamOnly() Logger
	WithPrefix(prefix string) Logger
	WithPrefixColor(prefix, color string) Logger
	WithSink(sink Logger) Logger
	AddSink(sink Logger)
}

Logger defines the common logging interface

func GetBaseInstance

func GetBaseInstance() Logger

GetBaseInstance returns the base stdout logger

func GetFileLogger

func GetFileLogger(filename string) Logger

GetFileLogger returns a logger instance for the specified filename

func GetInstance

func GetInstance() Logger

GetInstance returns the Logger instance

func NewStdoutLogger

func NewStdoutLogger(stdout, stderr io.Writer, level logrus.Level) Logger

func NewStreamLogger

func NewStreamLogger(stdout, stderr io.Writer, level logrus.Level) Logger

func NewStreamLoggerWithFormat

func NewStreamLoggerWithFormat(stdout, stderr io.Writer, level logrus.Level, format Format) Logger

type NopCloser

type NopCloser struct {
	io.Writer
}

func (NopCloser) Close

func (NopCloser) Close() error

type Prefix

type Prefix struct {
	Prefix string
	Color  string
}

type StreamLogger

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

func (*StreamLogger) AddSink

func (s *StreamLogger) AddSink(log Logger)

func (*StreamLogger) Children

func (s *StreamLogger) Children() []Logger

func (*StreamLogger) Debug

func (s *StreamLogger) Debug(args ...interface{})

func (*StreamLogger) Debugf

func (s *StreamLogger) Debugf(format string, args ...interface{})

func (*StreamLogger) Done

func (s *StreamLogger) Done(args ...interface{})

func (*StreamLogger) Donef

func (s *StreamLogger) Donef(format string, args ...interface{})

func (*StreamLogger) Error

func (s *StreamLogger) Error(args ...interface{})

func (*StreamLogger) ErrorStreamOnly

func (s *StreamLogger) ErrorStreamOnly() Logger

func (*StreamLogger) Errorf

func (s *StreamLogger) Errorf(format string, args ...interface{})

func (*StreamLogger) Fatal

func (s *StreamLogger) Fatal(args ...interface{})

func (*StreamLogger) Fatalf

func (s *StreamLogger) Fatalf(format string, args ...interface{})

func (*StreamLogger) GetFormat

func (s *StreamLogger) GetFormat() Format

func (*StreamLogger) GetLevel

func (s *StreamLogger) GetLevel() logrus.Level

func (*StreamLogger) Info

func (s *StreamLogger) Info(args ...interface{})

func (*StreamLogger) Infof

func (s *StreamLogger) Infof(format string, args ...interface{})

func (*StreamLogger) Print

func (s *StreamLogger) Print(level logrus.Level, args ...interface{})

func (*StreamLogger) Printf

func (s *StreamLogger) Printf(level logrus.Level, format string, args ...interface{})

func (*StreamLogger) Question

func (s *StreamLogger) Question(params *survey.QuestionOptions) (string, error)

func (*StreamLogger) SetLevel

func (s *StreamLogger) SetLevel(level logrus.Level)

func (*StreamLogger) Warn

func (s *StreamLogger) Warn(args ...interface{})

func (*StreamLogger) Warnf

func (s *StreamLogger) Warnf(format string, args ...interface{})

func (*StreamLogger) WithLevel

func (s *StreamLogger) WithLevel(level logrus.Level) Logger

func (*StreamLogger) WithPrefix

func (s *StreamLogger) WithPrefix(prefix string) Logger

func (*StreamLogger) WithPrefixColor

func (s *StreamLogger) WithPrefixColor(prefix, color string) Logger

func (*StreamLogger) WithSink

func (s *StreamLogger) WithSink(log Logger) Logger

func (*StreamLogger) WriteString

func (s *StreamLogger) WriteString(level logrus.Level, message string)

func (*StreamLogger) Writer

func (s *StreamLogger) Writer(level logrus.Level, raw bool) io.WriteCloser

type SurveyError

type SurveyError struct{}

SurveyError is used to identify errors where questions were asked in the discard logger

func (SurveyError) Error

func (s SurveyError) Error() string

Error implements error interface

Jump to

Keyboard shortcuts

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