log

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoType = iota
	ErrorType
	NodeType
	ServiceType
	StringType
	IntType
	UintType
	BytesType
	FloatType
	FunctionType
	SourceType
	StringArrayType
	TimeType
	AggregateType
)
View Source
const (
	SPACE  = " "
	EQUALS = "="
)
View Source
const DEFAULT_TIMESTAMP_COLUMN = "timestamp"
View Source
const POST_TERMINATED_ERROR = "*** Logged error after TestOutput.TestTerminated:"
View Source
const TEST_FAILED_ERROR = "" /* 169-byte string literal not displayed */
View Source
const TEST_RUNNER_PANIC_ERROR = "*** Test runner panic while trying to fail test (try using TestOutput.TestTerminated):"
View Source
const TIMESTAMP_FORMAT = "2006-01-02T15:04:05.999999999Z"

Variables

This section is empty.

Functions

func NewHttpWriter

func NewHttpWriter(url string) io.Writer

func NewJsonFormatter

func NewJsonFormatter() *jsonFormatter

Types

type AggregateField

type AggregateField interface {
	NestedFields() []*Field
}

type BasicLogger

type BasicLogger interface {
	Log(level string, message string, params ...*Field)
	LogFailedExpectation(message string, expected *Field, actual *Field, params ...*Field)
	Info(message string, params ...*Field)
	Error(message string, params ...*Field)
	Metric(params ...*Field)
	WithTags(params ...*Field) BasicLogger
	Tags() []*Field
	WithOutput(writer ...Output) BasicLogger
	WithFilters(filter ...Filter) BasicLogger
	Filters() []Filter
}

func DefaultTestingLogger added in v0.8.0

func DefaultTestingLogger(tb testing.TB) BasicLogger

func DefaultTestingLoggerAllowingErrors added in v0.8.1

func DefaultTestingLoggerAllowingErrors(tb testing.TB, errorPattern string) BasicLogger

func GetLogger

func GetLogger(params ...*Field) BasicLogger

type ConditionalFilter added in v0.8.1

type ConditionalFilter interface {
	Filter
	On()
	Off()
}

func NewConditionalFilter added in v0.8.1

func NewConditionalFilter(enabled bool, filter Filter) ConditionalFilter

type Field

type Field struct {
	Key  string
	Type FieldType

	StringVal   string
	StringArray []string
	Int         int64
	Uint        uint64
	Bytes       []byte
	Float       float64

	Error  error
	Nested AggregateField
}

func BlockHeight

func BlockHeight(value primitives.BlockHeight) *Field

func Bytes

func Bytes(key string, value []byte) *Field

func Error

func Error(value error) *Field

func Float32

func Float32(key string, value float32) *Field

func Float64

func Float64(key string, value float64) *Field

func Function

func Function(value string) *Field

func Int

func Int(key string, value int) *Field

func Int32

func Int32(key string, value int32) *Field

func Int64

func Int64(key string, value int64) *Field

func Node

func Node(value string) *Field

func Query added in v0.8.0

func Query(queryHash primitives.Sha256) *Field

func Service

func Service(value string) *Field

func Source

func Source(value string) *Field

func String

func String(key string, value string) *Field

func Stringable

func Stringable(key string, value fmt.Stringer) *Field

func StringableSlice

func StringableSlice(key string, values interface{}) *Field

func Timestamp

func Timestamp(key string, value time.Time) *Field

func TimestampNano

func TimestampNano(key string, value primitives.TimestampNano) *Field

func Transaction

func Transaction(txHash primitives.Sha256) *Field

func Uint

func Uint(key string, value uint) *Field

func Uint32

func Uint32(key string, value uint32) *Field

func Uint64

func Uint64(key string, value uint64) *Field

func VirtualChainId

func VirtualChainId(value primitives.VirtualChainId) *Field

func (*Field) Equal

func (f *Field) Equal(other *Field) bool

func (*Field) IsNested

func (f *Field) IsNested() bool

func (*Field) String

func (f *Field) String() string

func (*Field) Value

func (f *Field) Value() interface{}

type FieldType

type FieldType uint8

type Filter

type Filter interface {
	Allows(level string, message string, fields []*Field) bool
}

func DiscardAll

func DiscardAll() Filter

func ExcludeEntryPoint

func ExcludeEntryPoint(name string) Filter

func ExcludeField

func ExcludeField(field *Field) Filter

func IgnoreErrorsMatching

func IgnoreErrorsMatching(pattern string) Filter

func IgnoreMessagesMatching

func IgnoreMessagesMatching(pattern string) Filter

func IncludeFieldWithKey

func IncludeFieldWithKey(key string) Filter

func MatchField

func MatchField(f *Field) Filter

func OnlyCheckpoints

func OnlyCheckpoints() Filter

func OnlyErrors

func OnlyErrors() Filter

func OnlyMetrics

func OnlyMetrics() Filter

func Or

func Or(filters ...Filter) Filter

type LogFormatter

type LogFormatter interface {
	FormatRow(timestamp time.Time, level string, message string, params ...*Field) (formattedRow string)
}

func NewHumanReadableFormatter

func NewHumanReadableFormatter() LogFormatter

type Output

type Output interface {
	Append(level string, message string, fields ...*Field)
}

func NewBulkOutput

func NewBulkOutput(writer io.Writer, formatter LogFormatter, bulkSize int) Output

func NewFormattingOutput

func NewFormattingOutput(writer io.Writer, formatter LogFormatter) Output

type TLog added in v0.8.1

type TLog interface {
	Fatal(args ...interface{})
	Log(args ...interface{})
	Error(args ...interface{})
	Name() string
}

type TestOutput added in v0.8.1

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

func NewTestOutput added in v0.8.0

func NewTestOutput(tb TLog, formatter LogFormatter) *TestOutput

func (*TestOutput) AllowErrorsMatching added in v0.8.1

func (o *TestOutput) AllowErrorsMatching(pattern string)

func (*TestOutput) Append added in v0.8.1

func (o *TestOutput) Append(level string, message string, fields ...*Field)

func (*TestOutput) HasErrors added in v0.8.1

func (o *TestOutput) HasErrors() bool

func (*TestOutput) TestTerminated added in v0.9.2

func (o *TestOutput) TestTerminated()

the golang test runner throws a severe panic if trying to fail a test after it already passed this happens for example on t.Run where a goroutine logs an Error (which fails the test) after t.Run passed the solution is to add "defer testOutput.TestTerminated()" to execute as the t.Run body is returning

type TruncatingFileWriter added in v0.8.0

type TruncatingFileWriter interface {
	io.Writer
	Truncate() error
}

func NewTruncatingFileWriter added in v0.8.0

func NewTruncatingFileWriter(f *os.File, intervals ...time.Duration) TruncatingFileWriter

Jump to

Keyboard shortcuts

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