log

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: Apache-2.0 Imports: 5 Imported by: 25

Documentation

Overview

Package log provides debug logging

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLog logger
	DefaultLog = NewLog()
	// DefaultLevel is default log level
	DefaultLevel = LevelInfo
)
View Source
var (
	// DefaultSize of the logger buffer
	DefaultSize = 1000
)

Functions

func Debug

func Debug(v ...interface{})

Debug provides debug level logging

func Debugf

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

Debugf provides debug level logging

func Error

func Error(v ...interface{})

Error provides warn level logging

func Errorf

func Errorf(format string, v ...interface{})

Errorf provides warn level logging

func Fatal

func Fatal(v ...interface{})

Fatal logs with Log and then exits with os.Exit(1)

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf logs with Logf and then exits with os.Exit(1)

func Info

func Info(v ...interface{})

Info provides info level logging

func Infof

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

Infof provides info level logging

func Name

func Name(name string)

Set service name

func SetLevel

func SetLevel(l Level)

SetLevel sets the log level

func SetPrefix

func SetPrefix(p string)

Set a prefix for the logger

func Trace

func Trace(v ...interface{})

Trace provides trace level logging

func Tracef

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

Tracef provides trace level logging

func Warn

func Warn(v ...interface{})

Warn provides warn level logging

func Warnf

func Warnf(format string, v ...interface{})

Warnf provides warn level logging

func WithLevel

func WithLevel(l Level, v ...interface{})

WithLevel logs with the level specified

func WithLevelf

func WithLevelf(l Level, format string, v ...interface{})

WithLevel logs with the level specified

Types

type Level

type Level int

level is a log level

const (
	LevelFatal Level = iota
	LevelError
	LevelInfo
	LevelWarn
	LevelDebug
	LevelTrace
)

func GetLevel

func GetLevel() Level

GetLevel returns the current level

type Log

type Log interface {
	// Read reads log entries from the logger
	Read(...ReadOption) []Record
	// Write writes records to log
	Write(Record)
	// Stream log records
	Stream(chan bool) <-chan Record
}

Log is event log

func NewLog

func NewLog(opts ...Option) Log

NewLog returns default Logger with

type Option

type Option func(*Options)

Option used by the logger

func Size

func Size(s int) Option

Size sets the size of the ring buffer

type Options

type Options struct {
	// Size is the size of ring buffer
	Size int
}

Options are logger options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default options

type ReadOption

type ReadOption func(*ReadOptions)

ReadOption used for reading the logs

func Count

func Count(c int) ReadOption

Count sets the number of log records to return

func Since

func Since(s time.Time) ReadOption

Since sets the time since which to return the log records

func Stream

func Stream(s bool) ReadOption

Stream requests continuous log stream

type ReadOptions

type ReadOptions struct {
	// Since what time in past to return the logs
	Since time.Time
	// Count specifies number of logs to return
	Count int
	// Stream requests continuous log stream
	Stream bool
}

ReadOptions for querying the logs

type Record

type Record struct {
	// Timestamp of logged event
	Timestamp time.Time
	// Value contains log entry
	Value interface{}
	// Metadata to enrich log record
	Metadata map[string]string
}

Record is log record entry

Jump to

Keyboard shortcuts

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