Documentation ¶
Overview ¶
Package console allows for log messages to be sent to a any writer, default os.Stderr.
Example ¶
simple console
package main import ( "github.com/go-playground/log" "github.com/go-playground/log/handlers/console" ) func main() { cLog := console.New() log.RegisterHandler(cLog, log.AllLevels...) // Trace defer log.Trace("trace").End() log.Debug("debug") log.Info("info") log.Notice("notice") log.Warn("warn") log.Error("error") // log.Panic("panic") // this will panic log.Alert("alert") // log.Fatal("fatal") // this will call os.Exit(1) // logging with fields can be used with any of the above log.WithFields(log.F("key", "value")).Info("test info") }
Index ¶
- type Console
- func (c *Console) DisplayColor() bool
- func (c *Console) FilenameDisplay() log.FilenameDisplay
- func (c *Console) GOPATH() string
- func (c *Console) GetDisplayColor(level log.Level) log.ANSIEscSeq
- func (c *Console) RedirectSTDLogOutput(b bool)
- func (c *Console) Run() chan<- *log.Entry
- func (c *Console) SetBuffersAndWorkers(size uint, workers uint)
- func (c *Console) SetDisplayColor(color bool)
- func (c *Console) SetFilenameDisplay(fd log.FilenameDisplay)
- func (c *Console) SetFormatFunc(fn FormatFunc)
- func (c *Console) SetTimestampFormat(format string)
- func (c *Console) SetWriter(w io.Writer)
- func (c *Console) TimestampFormat() string
- type FormatFunc
- type Formatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console is an instance of the console logger
func (*Console) DisplayColor ¶
DisplayColor returns if logging color or not
func (*Console) FilenameDisplay ¶
func (c *Console) FilenameDisplay() log.FilenameDisplay
FilenameDisplay returns Console's current filename display setting
func (*Console) GetDisplayColor ¶
func (c *Console) GetDisplayColor(level log.Level) log.ANSIEscSeq
GetDisplayColor returns the color for the given log level
func (*Console) RedirectSTDLogOutput ¶
RedirectSTDLogOutput tells Console to redirect the std Logger output to the log package itself.
func (*Console) SetBuffersAndWorkers ¶
SetBuffersAndWorkers sets the channels buffer size and number of concurrent workers. These settings should be thought about together, hence setting both in the same function.
func (*Console) SetDisplayColor ¶
SetDisplayColor tells Console to output in color or not Default is : true
func (*Console) SetFilenameDisplay ¶
func (c *Console) SetFilenameDisplay(fd log.FilenameDisplay)
SetFilenameDisplay tells Console the filename, when present, how to display
func (*Console) SetFormatFunc ¶
func (c *Console) SetFormatFunc(fn FormatFunc)
SetFormatFunc sets FormatFunc each worker will call to get a Formatter func
func (*Console) SetTimestampFormat ¶
SetTimestampFormat sets Console's timestamp output format Default is : "2006-01-02T15:04:05.000000000Z07:00"
func (*Console) TimestampFormat ¶
TimestampFormat returns Console's current timestamp output format
type FormatFunc ¶
FormatFunc is the function that the workers use to create a new Formatter per worker allowing reusable go routine safe variable to be used within your Formatter function.