logger

package
v1.0.14-1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: BSD-3-Clause, BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path string) (bool, error)

func MakeParentDirs

func MakeParentDirs(filename string) error

func NewContextWithLogTags

func NewContextWithLogTags(
	ctx context.Context, logTagsToAdd CtxLogTags) context.Context

NewContext returns a new Context that carries adds the given log tag mappings (context key -> display string).

func OpenLogFile

func OpenLogFile(filename string) (name string, file *os.File, err error)

func PickFirstError

func PickFirstError(errors ...error) error

Types

type CtxLogTags

type CtxLogTags map[interface{}]string

func LogTagsFromContext

func LogTagsFromContext(ctx context.Context) (CtxLogTags, bool)

LogTagsFromContext returns the log tags being passed along with the given context.

type CtxStandardLoggerKey

type CtxStandardLoggerKey int

CtxStandardLoggerKey is a type defining context keys used by the Standard logger.

const (
	// CtxLogTags defines a context key that can hold a slice of context
	// keys, the value of which should be logged by a Standard logger if
	// one of those keys is seen in a context during a log call.
	CtxLogTagsKey CtxStandardLoggerKey = iota
)

type ExternalHandler

type ExternalHandler interface {
	Log(level keybase1.LogLevel, format string, args []interface{})
}

type ExternalLogger

type ExternalLogger interface {
	Log(level keybase1.LogLevel, format string, args []interface{})
}

type Logger

type Logger interface {
	// Debug logs a message at debug level, with formatting args.
	Debug(format string, args ...interface{})
	// CDebugf logs a message at debug level, with a context and
	// formatting args.
	CDebugf(ctx context.Context, format string, args ...interface{})
	// Info logs a message at info level, with formatting args.
	Info(format string, args ...interface{})
	// CInfo logs a message at info level, with a context and formatting args.
	CInfof(ctx context.Context, format string, args ...interface{})
	// Notice logs a message at notice level, with formatting args.
	Notice(format string, args ...interface{})
	// CNoticef logs a message at notice level, with a context and
	// formatting args.
	CNoticef(ctx context.Context, format string, args ...interface{})
	// Warning logs a message at warning level, with formatting args.
	Warning(format string, args ...interface{})
	// CWarning logs a message at warning level, with a context and
	// formatting args.
	CWarningf(ctx context.Context, format string, args ...interface{})
	// Error logs a message at error level, with formatting args
	Error(format string, args ...interface{})
	// Errorf logs a message at error level, with formatting args.
	Errorf(format string, args ...interface{})
	// CErrorf logs a message at error level, with a context and
	// formatting args.
	CErrorf(ctx context.Context, format string, args ...interface{})
	// Critical logs a message at critical level, with formatting args.
	Critical(format string, args ...interface{})
	// CCriticalf logs a message at critical level, with a context and
	// formatting args.
	CCriticalf(ctx context.Context, format string, args ...interface{})
	// Fatalf logs a message at fatal level, with formatting args.
	Fatalf(format string, args ...interface{})
	// Fatalf logs a message at fatal level, with a context and formatting args.
	CFatalf(ctx context.Context, format string, args ...interface{})
	// Profile logs a profile message, with formatting args.
	Profile(fmts string, arg ...interface{})
	// Configure sets the style, debug level, and filename of the
	// logger.  Output isn't redirected to the file until
	// RotateLogFile is called for the first time.
	Configure(style string, debug bool, filename string)
	// RotateLogFile rotates the log file, if the underlying logger is
	// writing to a file.
	RotateLogFile() error

	// SetExternalHandler sets a handler that will be called with every log message.
	SetExternalHandler(handler ExternalHandler)
}

type Null

type Null struct{}

func NewNull

func NewNull() *Null

func (*Null) CCriticalf

func (l *Null) CCriticalf(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CDebugf

func (l *Null) CDebugf(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CErrorf

func (l *Null) CErrorf(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CFatalf

func (l *Null) CFatalf(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CInfof

func (l *Null) CInfof(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CNoticef

func (l *Null) CNoticef(ctx context.Context, fmt string, arg ...interface{})

func (*Null) CWarningf

func (l *Null) CWarningf(ctx context.Context, fmt string, arg ...interface{})

func (*Null) Configure

func (l *Null) Configure(style string, debug bool, filename string)

func (*Null) Critical

func (l *Null) Critical(format string, args ...interface{})

func (*Null) Debug

func (l *Null) Debug(format string, args ...interface{})

func (*Null) Error

func (l *Null) Error(fmt string, arg ...interface{})

func (*Null) Errorf

func (l *Null) Errorf(format string, args ...interface{})

func (*Null) Fatalf

func (l *Null) Fatalf(fmt string, arg ...interface{})

func (*Null) Info

func (l *Null) Info(format string, args ...interface{})

func (*Null) Notice

func (l *Null) Notice(format string, args ...interface{})

func (*Null) Profile

func (l *Null) Profile(fmts string, arg ...interface{})

func (*Null) RotateLogFile

func (l *Null) RotateLogFile() error

func (*Null) SetExternalHandler

func (l *Null) SetExternalHandler(handler ExternalHandler)

func (*Null) Shutdown

func (l *Null) Shutdown()

func (*Null) Warning

func (l *Null) Warning(format string, args ...interface{})

type Standard

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

func New

func New(module string, iow io.Writer) *Standard

New creates a new Standard logger for module.

func NewWithCallDepth

func NewWithCallDepth(module string, extraCallDepth int, iow io.Writer) *Standard

NewWithCallDepth creates a new Standard logger for module, and when printing file names and line numbers, it goes extraCallDepth up the stack from where logger was invoked.

func (*Standard) CCriticalf

func (log *Standard) CCriticalf(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CDebugf

func (log *Standard) CDebugf(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CErrorf

func (log *Standard) CErrorf(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CFatalf

func (log *Standard) CFatalf(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CInfof

func (log *Standard) CInfof(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CNoticef

func (log *Standard) CNoticef(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) CWarningf

func (log *Standard) CWarningf(ctx context.Context, fmt string,
	arg ...interface{})

func (*Standard) Configure

func (log *Standard) Configure(style string, debug bool, filename string)

func (*Standard) Critical

func (log *Standard) Critical(fmt string, arg ...interface{})

func (*Standard) Debug

func (log *Standard) Debug(fmt string, arg ...interface{})

func (*Standard) Error

func (log *Standard) Error(fmt string, arg ...interface{})

func (*Standard) Errorf

func (log *Standard) Errorf(fmt string, arg ...interface{})

func (*Standard) Fatalf

func (log *Standard) Fatalf(fmt string, arg ...interface{})

func (*Standard) GetUnforwardedLogger

func (log *Standard) GetUnforwardedLogger() *UnforwardedLogger

func (*Standard) Info

func (log *Standard) Info(fmt string, arg ...interface{})

func (*Standard) Notice

func (log *Standard) Notice(fmt string, arg ...interface{})

func (*Standard) Profile

func (log *Standard) Profile(fmts string, arg ...interface{})

func (*Standard) RotateLogFile

func (log *Standard) RotateLogFile() error

func (*Standard) SetExternalHandler

func (log *Standard) SetExternalHandler(handler ExternalHandler)

func (*Standard) Warning

func (log *Standard) Warning(fmt string, arg ...interface{})

type TestLogBackend

type TestLogBackend interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Log(args ...interface{})
	Logf(format string, args ...interface{})
}

TestLogBackend is an interface for logging to a test object (i.e., a *testing.T). We define this in order to avoid pulling in the "testing" package in exported code.

type TestLogger

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

TestLogger is a Logger that writes to a TestLogBackend. All messages except Fatal are printed using Logf, to avoid failing a test that is trying to test an error condition. No context tags are logged.

func NewTestLogger

func NewTestLogger(log TestLogBackend) *TestLogger

func (*TestLogger) CCriticalf

func (log *TestLogger) CCriticalf(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CDebugf

func (log *TestLogger) CDebugf(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CErrorf

func (log *TestLogger) CErrorf(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CFatalf

func (log *TestLogger) CFatalf(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CInfof

func (log *TestLogger) CInfof(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CNoticef

func (log *TestLogger) CNoticef(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) CWarningf

func (log *TestLogger) CWarningf(ctx context.Context, fmts string,
	arg ...interface{})

func (*TestLogger) Configure

func (log *TestLogger) Configure(style string, debug bool, filename string)

func (*TestLogger) Critical

func (log *TestLogger) Critical(fmts string, arg ...interface{})

func (*TestLogger) Debug

func (log *TestLogger) Debug(fmts string, arg ...interface{})

func (*TestLogger) Error

func (log *TestLogger) Error(fmts string, arg ...interface{})

func (*TestLogger) Errorf

func (log *TestLogger) Errorf(fmts string, arg ...interface{})

func (*TestLogger) Fatalf

func (log *TestLogger) Fatalf(fmts string, arg ...interface{})

func (*TestLogger) Info

func (log *TestLogger) Info(fmts string, arg ...interface{})

func (*TestLogger) Notice

func (log *TestLogger) Notice(fmts string, arg ...interface{})

func (*TestLogger) Profile

func (log *TestLogger) Profile(fmts string, arg ...interface{})

func (*TestLogger) RotateLogFile

func (log *TestLogger) RotateLogFile() error

func (*TestLogger) SetExternalHandler

func (log *TestLogger) SetExternalHandler(_ ExternalHandler)

no-op stubs to fulfill the Logger interface

func (*TestLogger) Warning

func (log *TestLogger) Warning(fmts string, arg ...interface{})

type UnforwardedLogger

type UnforwardedLogger Standard

func (*UnforwardedLogger) Debug

func (log *UnforwardedLogger) Debug(s string, args ...interface{})

func (*UnforwardedLogger) Error

func (log *UnforwardedLogger) Error(s string, args ...interface{})

func (*UnforwardedLogger) Errorf

func (log *UnforwardedLogger) Errorf(s string, args ...interface{})

func (*UnforwardedLogger) Info

func (log *UnforwardedLogger) Info(s string, args ...interface{})

func (*UnforwardedLogger) Profile

func (log *UnforwardedLogger) Profile(s string, args ...interface{})

func (*UnforwardedLogger) Warning

func (log *UnforwardedLogger) Warning(s string, args ...interface{})

Jump to

Keyboard shortcuts

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