golog: github.com/vardius/golog Index | Examples | Files

package golog

import "github.com/vardius/golog"

Index

Examples

Package Files

console.go file.go logger.go

Constants

const (
    CLR_0 = "\x1b[30;1m"
    CLR_R = "\x1b[31;1m"
    CLR_G = "\x1b[32;1m"
    CLR_Y = "\x1b[33;1m"
    CLR_B = "\x1b[34;1m"
    CLR_M = "\x1b[35;1m"
    CLR_C = "\x1b[36;1m"
    CLR_W = "\x1b[37;1m"
    CLR_N = "\x1b[0m"
)

Terminal colours.

const (
    DebugPrefix = "DEBUG: "
    InfoPrefix  = "INFO: "
    WarnPrefix  = "WARN: "
    ErrorPrefix = "ERROR: "
    FatalPrefix = "FATAL: "

    DebugLevel    = 4
    InfoLevel     = 3
    WarningLevel  = 2
    ErrorLevel    = 1
    CriticalLevel = 0

    DefaultFlags = log.Ldate | log.Ltime | log.Lmicroseconds | log.LUTC
)

Variables

var New loggerFactory

type Logger Uses

type Logger interface {
    Debug(ctx context.Context, format string, args ...interface{})
    Info(ctx context.Context, format string, args ...interface{})
    Warning(ctx context.Context, format string, args ...interface{})
    Error(ctx context.Context, format string, args ...interface{})
    Critical(ctx context.Context, format string, args ...interface{})
}

func NewConsoleLogger Uses

func NewConsoleLogger(verbose string) Logger

NewConsoleLogger returns a Logger that writes to the console.

Code:

log := golog.NewConsoleLogger("warn")
ctx := context.TODO()

// log.Info won't print to the console because it is below loglevel "warn"
log.Info(ctx, "%s", "Info")
// log.Warning and log.Error will both get printed
log.Warning(ctx, "%s %d", "Warn", 1)
log.Error(ctx, "%s %d", "Error", 666)

func NewFileLogger Uses

func NewFileLogger(verbose, filePath string) Logger

Package golog imports 3 packages (graph) and is imported by 9 packages. Updated 2019-01-17. Refresh now. Tools for package owners.