console

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2016 License: MIT Imports: 7 Imported by: 30

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

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 New

func New() *Console

New returns a new instance of the console logger

func (*Console) DisplayColor

func (c *Console) DisplayColor() bool

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) GOPATH

func (c *Console) GOPATH() string

GOPATH returns the GOPATH calculated by Console

func (*Console) GetDisplayColor

func (c *Console) GetDisplayColor(level log.Level) log.ANSIEscSeq

GetDisplayColor returns the color for the given log level

func (*Console) RedirectSTDLogOutput

func (c *Console) RedirectSTDLogOutput(b bool)

RedirectSTDLogOutput tells Console to redirect the std Logger output to the log package itself.

func (*Console) Run

func (c *Console) Run() chan<- *log.Entry

Run starts the logger consuming on the returned channed

func (*Console) SetBuffersAndWorkers

func (c *Console) SetBuffersAndWorkers(size uint, workers uint)

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

func (c *Console) SetDisplayColor(color bool)

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

func (c *Console) SetTimestampFormat(format string)

SetTimestampFormat sets Console's timestamp output format Default is : "2006-01-02T15:04:05.000000000Z07:00"

func (*Console) SetWriter

func (c *Console) SetWriter(w io.Writer)

SetWriter sets Console's wriiter Default is : os.Stderr

func (*Console) TimestampFormat

func (c *Console) TimestampFormat() string

TimestampFormat returns Console's current timestamp output format

type FormatFunc

type FormatFunc func(c *Console) Formatter

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.

type Formatter

type Formatter func(e *log.Entry) []byte

Formatter is the function used to format the Redis entry

Jump to

Keyboard shortcuts

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