logger: github.com/azer/logger Index | Files | Directories

package logger

import "github.com/azer/logger"


Package Files

format.go log.go logger.go runtime.go standard-output.go

func Hook Uses

func Hook(writer OutputWriter)

Add a new writer

func Now Uses

func Now() int64

Now is a shortcut for returning the current time in Unix nanoseconds.

func SetOutput Uses

func SetOutput(file *os.File)

Legacy method

type Attrs Uses

type Attrs map[string]interface{}

func SplitAttrs Uses

func SplitAttrs(v []interface{}) ([]interface{}, *Attrs)

SplitAttrs checks if the last item passed in v is an Attrs instance, if so it returns it separately. If not, v is returned as-is with a nil Attrs.

type Log Uses

type Log struct {
    Package     string `json:"package"`
    Level       string `json:"level"`
    Message     string `json:"msg"`
    Attrs       *Attrs `json:"attrs"`
    Time        int64  `json:"time"`
    Elapsed     int64  `json:"elapsed"`
    ElapsedNano int64  `json:"elapsed_nano"`

func (*Log) End Uses

func (log *Log) End(msg string, args ...interface{})

type Logger Uses

type Logger struct {
    // Name by which the logger is identified when enabling or disabling it, and by envvar.
    Name string

Logger is the unit of the logger package, a smart, pretty-printing gate between the program and the output stream.

func New Uses

func New(name string) *Logger

New returns a logger bound to the given name.

func (*Logger) Error Uses

func (l *Logger) Error(msg string, v ...interface{})

Error logs an error message.

func (*Logger) Info Uses

func (l *Logger) Info(msg string, v ...interface{})

Info prints log information to the screen that is informational in nature.

func (*Logger) Log Uses

func (logger *Logger) Log(level, message string, args []interface{})

func (*Logger) Timer Uses

func (l *Logger) Timer() *Log

Timer returns a timer sub-logger.

type OutputSettings Uses

type OutputSettings struct {
    Info  bool
    Timer bool
    Error bool

type OutputWriter Uses

type OutputWriter interface {
    Write(log *Log)

func NewStandardOutput Uses

func NewStandardOutput(file *os.File) OutputWriter

type Runtime Uses

type Runtime struct {
    Writers []OutputWriter

func (*Runtime) Log Uses

func (runtime *Runtime) Log(log *Log)

type StandardWriter Uses

type StandardWriter struct {
    ColorsEnabled bool
    Target        *os.File
    Settings      map[string]*OutputSettings

func (*StandardWriter) Format Uses

func (sw *StandardWriter) Format(log *Log) string

func (StandardWriter) Init Uses

func (standardWriter StandardWriter) Init()

func (*StandardWriter) IsEnabled Uses

func (sw *StandardWriter) IsEnabled(logger, level string) bool

func (*StandardWriter) JSONFormat Uses

func (sw *StandardWriter) JSONFormat(log *Log) string

func (*StandardWriter) LoggerSettings Uses

func (sw *StandardWriter) LoggerSettings(p string) *OutputSettings

func (*StandardWriter) PrettyAttrs Uses

func (sw *StandardWriter) PrettyAttrs(attrs *Attrs) string

func (*StandardWriter) PrettyFormat Uses

func (sw *StandardWriter) PrettyFormat(log *Log) string

func (*StandardWriter) PrettyLabel Uses

func (sw *StandardWriter) PrettyLabel(log *Log) string

func (*StandardWriter) PrettyLabelExt Uses

func (sw *StandardWriter) PrettyLabelExt(log *Log) string

func (StandardWriter) Write Uses

func (sw StandardWriter) Write(log *Log)



Package logger imports 7 packages (graph) and is imported by 33 packages. Updated 2020-04-01. Refresh now. Tools for package owners.