luci: go.chromium.org/luci/common/logging/memlogger Index | Files

package memlogger

import "go.chromium.org/luci/common/logging/memlogger"

Index

Package Files

assertions.go memory.go

func Dump Uses

func Dump(c context.Context, w io.Writer) (n int, err error)

Dump is a convenience function to dump the current contents of the memory logger to the writer.

This will panic if the current logger is not a memory logger.

func MustDumpStdout Uses

func MustDumpStdout(c context.Context)

MustDumpStdout is a convenience function to dump the current contents of the memory logger to stdout.

This will panic if the current logger is not a memory logger.

func Reset Uses

func Reset(c context.Context)

Reset is a convenience function to reset the current memory logger.

This will panic if the current logger is not a memory logger.

func ShouldHaveLog Uses

func ShouldHaveLog(actual interface{}, expected ...interface{}) string

ShouldHaveLog is a goconvey custom assertion which asserts that the logger has received a log. It takes up to 3 arguments. argument 1 (expected[0]) is the log level. argument 2 (expected[1]) is a substring the message. If omitted or the empty string, this value is not checked. argument 3 (expected[2]) is the fields data. If omitted or nil, this value is not checked.

func ShouldNotHaveLog Uses

func ShouldNotHaveLog(actual interface{}, expected ...interface{}) string

ShouldNotHaveLog is the inverse of ShouldHaveLog. It asserts that the logger has not seen such a log.

func Use Uses

func Use(c context.Context) context.Context

Use adds a memory backed Logger to Context, with concrete type *MemLogger. Casting to the concrete type can be used to inspect the log output after running a test case, for example.

type LogEntry Uses

type LogEntry struct {
    Level     logging.Level
    Msg       string
    Data      map[string]interface{}
    CallDepth int
}

LogEntry is a single entry in a MemLogger, containing a message and a severity.

type MemLogger Uses

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

MemLogger is an implementation of Logger. Zero value is a valid logger.

func (*MemLogger) Debugf Uses

func (m *MemLogger) Debugf(format string, args ...interface{})

Debugf implements the logging.Logger interface.

func (*MemLogger) Dump Uses

func (m *MemLogger) Dump(w io.Writer) (n int, err error)

Dump dumps the current memory logger contents to the given writer in a human-readable format.

func (*MemLogger) Errorf Uses

func (m *MemLogger) Errorf(format string, args ...interface{})

Errorf implements the logging.Logger interface.

func (*MemLogger) Get Uses

func (m *MemLogger) Get(lvl logging.Level, msg string, data map[string]interface{}) *LogEntry

Get returns the first matching log entry. Note that lvl, msg and data have to match the entry precisely.

func (*MemLogger) GetFunc Uses

func (m *MemLogger) GetFunc(f func(*LogEntry) bool) *LogEntry

GetFunc returns the first matching log entry.

func (*MemLogger) Has Uses

func (m *MemLogger) Has(lvl logging.Level, msg string, data map[string]interface{}) bool

Has returns true iff the MemLogger contains the specified log message. Note that lvl, msg and data have to match the entry precisely.

func (*MemLogger) HasFunc Uses

func (m *MemLogger) HasFunc(f func(*LogEntry) bool) bool

HasFunc returns true iff the MemLogger contains a matching log message.

func (*MemLogger) Infof Uses

func (m *MemLogger) Infof(format string, args ...interface{})

Infof implements the logging.Logger interface.

func (*MemLogger) LogCall Uses

func (m *MemLogger) LogCall(lvl logging.Level, calldepth int, format string, args []interface{})

LogCall implements the logging.Logger interface.

func (*MemLogger) Messages Uses

func (m *MemLogger) Messages() []LogEntry

Messages returns all of the log messages that this memory logger has recorded.

func (*MemLogger) Reset Uses

func (m *MemLogger) Reset()

Reset resets the logged messages recorded so far.

func (*MemLogger) Warningf Uses

func (m *MemLogger) Warningf(format string, args ...interface{})

Warningf implements the logging.Logger interface.

Package memlogger imports 8 packages (graph) and is imported by 6 packages. Updated 2018-08-14. Refresh now. Tools for package owners.