std

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package std provides a logger implementation via the Go built-in logger.

Index

Constants

This section is empty.

Variables

View Source
var DefaultFmtFun = func(start time.Time, lvl log.LoggerLevel, msg string, fields []Field) string {
	timestr := color.CyanString(start.Format("02 15:04:05.000000"))
	lvlstr := ""
	switch lvl {
	case log.DebugLevel:
		lvlstr = fmt.Sprintf(" %s", color.New(color.Bold, color.FgYellow).Sprint("DBG"))
	case log.InfoLevel:
		lvlstr = fmt.Sprintf(" %s", color.New(color.Bold, color.FgGreen).Sprint("INF"))
	case log.ErrorLevel:
		lvlstr = fmt.Sprintf(" %s", color.New(color.Bold, color.FgRed).Sprint("ERR"))
	}
	fieldstr := ""
	for _, f := range fields {
		if fieldstr != "" {
			fieldstr += ", "
		}
		fieldstr += fmt.Sprintf("{%s: %v}", color.New(color.Bold).Sprint(f.Name), f.Value)
	}
	return fmt.Sprintf("%s%s %s %s", timestr, lvlstr, msg, fieldstr)
}

Functions

func NewFactory

func NewFactory(std *stdlog.Logger, min log.LoggerLevel, fmt FmtFun) log.Factory

func Use

func Use(out io.Writer, min log.LoggerLevel, fmt FmtFun)

Types

type Field

type Field struct {
	Name  string
	Value interface{}
}

type FmtFun

type FmtFun func(start time.Time, level log.LoggerLevel, msg string, fields []Field) string

Jump to

Keyboard shortcuts

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