log

package
v0.0.0-...-13f918f Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2016 License: MIT Imports: 4 Imported by: 0

README

Log Package

This package is a drop-in replacement for seelog that allows you to add a source and context to your logging messages.

Usage

Set log.Source at the start of your program. This will prefix all log messages with @source:

log.Source = "foo"
log.Infof("found it: %s", xyz)

outputs:

@foo found it: xyz

When you want to report a topic for every log message, create a new context and use that as your logger:

log.Source = "foo"
clog := log.NewContext("myid")
clog.Debugf("received request: %s", xyz)

outputs:

@foo #myid received request: xyz

You can also create sub-contexts:

sublog := clog.NewContext("process")
sublog.Debugf("doing something")

outputs:

@foo #myid #process doing something

Documentation

Overview

log is a drop-in replacement for seelog that allows you to add a source and context to your logging messages.

Index

Constants

This section is empty.

Variables

View Source
var Source string

Functions

func Critical

func Critical(v ...interface{}) error

Critical formats message using the default formats for its operands and writes to default logger with log level = Critical

func Criticalf

func Criticalf(format string, params ...interface{}) error

Criticalf formats message according to format specifier and writes to default logger with log level = Critical

func Debug

func Debug(v ...interface{})

Debug formats message using the default formats for its operands and writes to default logger with log level = Debug

func Debugf

func Debugf(format string, params ...interface{})

Debugf formats message according to format specifier and writes to default logger with log level = Debug.

func Disable

func Disable()

func Error

func Error(v ...interface{}) error

Error formats message using the default formats for its operands and writes to default logger with log level = Error

func Errorf

func Errorf(format string, params ...interface{}) error

Errorf formats message according to format specifier and writes to default logger with log level = Error

func Flush

func Flush()

Flush immediately processes all currently queued messages and all currently buffered messages. It is a blocking call which returns only after the queue is empty and all the buffers are empty.

If Flush is called for a synchronous logger (type='sync'), it only flushes buffers (e.g. '<buffered>' receivers) , because there is no queue.

Call this method when your app is going to shut down not to lose any log messages.

func Info

func Info(v ...interface{})

Info formats message using the default formats for its operands and writes to default logger with log level = Info

func Infof

func Infof(format string, params ...interface{})

Infof formats message according to format specifier and writes to default logger with log level = Info.

func Trace

func Trace(v ...interface{})

Trace formats message using the default formats for its operands and writes to default logger with log level = Trace

func Tracef

func Tracef(format string, params ...interface{})

Tracef formats message according to format specifier and writes to default logger with log level = Trace.

func Warn

func Warn(v ...interface{}) error

Warn formats message using the default formats for its operands and writes to default logger with log level = Warn

func Warnf

func Warnf(format string, params ...interface{}) error

Warnf formats message according to format specifier and writes to default logger with log level = Warn

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(topics ...string) *Context

func (*Context) AddContext

func (c *Context) AddContext(topics ...string)

func (*Context) Critical

func (c *Context) Critical(v ...interface{}) error

Critical formats message using the default formats for its operands and writes to default logger with log level = Critical Returns an error without the context decoration

func (*Context) Criticalf

func (c *Context) Criticalf(format string, params ...interface{}) error

Criticalf formats message according to format specifier and writes to default logger with log level = Critical Returns an error without the context decoration

func (*Context) Debug

func (c *Context) Debug(v ...interface{})

Debug formats message using the default formats for its operands and writes to default logger with log level = Debug

func (*Context) Debugf

func (c *Context) Debugf(format string, params ...interface{})

Debugf formats message according to format specifier and writes to default logger with log level = Debug.

func (*Context) Error

func (c *Context) Error(v ...interface{}) error

Error formats message using the default formats for its operands and writes to default logger with log level = Error Returns an error without the context decoration

func (*Context) Errorf

func (c *Context) Errorf(format string, params ...interface{}) error

Errorf formats message according to format specifier and writes to default logger with log level = Error Returns an error without the context decoration

func (*Context) Flush

func (c *Context) Flush()

Call this method when your app is going to shut down not to lose any log messages.

func (*Context) Info

func (c *Context) Info(v ...interface{})

Info formats message using the default formats for its operands and writes to default logger with log level = Info

func (*Context) Infof

func (c *Context) Infof(format string, params ...interface{})

Infof formats message according to format specifier and writes to default logger with log level = Info.

func (*Context) NewContext

func (c *Context) NewContext(topics ...string) *Context

func (*Context) Trace

func (c *Context) Trace(v ...interface{})

Trace formats message using the default formats for its operands and writes to default logger with log level = Trace

func (*Context) Tracef

func (c *Context) Tracef(format string, params ...interface{})

Tracef formats message according to format specifier and writes to default logger with log level = Trace.

func (*Context) Warn

func (c *Context) Warn(v ...interface{}) error

Warn formats message using the default formats for its operands and writes to default logger with log level = Warn Returns an error without the context decoration

func (*Context) Warnf

func (c *Context) Warnf(format string, params ...interface{}) error

Warnf formats message according to format specifier and writes to default logger with log level = Warn Returns an error without the context decoration

Jump to

Keyboard shortcuts

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