log

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 3 Imported by: 67

README

Go package strongo/log

Logging framework in Go language that uses context.Context to support GAE & other environments

Build Status Go Report Card GoDoc

Used by

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogger

func AddLogger(logger Logger)

AddLogger registers logger

func Criticalf

func Criticalf(c context.Context, format string, args ...interface{})

Criticalf logs critical message

func Debugf

func Debugf(c context.Context, format string, args ...interface{})

Debugf logs debug message

func Errorf

func Errorf(c context.Context, format string, args ...interface{})

Errorf logs error message

func Infof

func Infof(c context.Context, format string, args ...interface{})

Infof logs information message

func NewContextWithLoggingDisabled

func NewContextWithLoggingDisabled(c context.Context) context.Context

NewContextWithLoggingDisabled creates context with disabled logging

func NewContextWithLoggingEnabled

func NewContextWithLoggingEnabled(c context.Context) context.Context

NewContextWithLoggingEnabled creates context with enabled logging

func NumberOfLoggers

func NumberOfLoggers() int

NumberOfLoggers returns number of registered loggers

func Warningf

func Warningf(c context.Context, format string, args ...interface{})

Warningf logs warning message

Types

type Func

type Func func(c context.Context, format string, args ...interface{})

Func function that do logging

type Level

type Level int

Level specifies log record type

const (
	// LevelDebug for debug records
	LevelDebug Level = iota
	// LevelInfo for info records
	LevelInfo
	// LevelWarning for warnings
	LevelWarning
	// LevelError for errors
	LevelError
	// LevelCritical for critical records
	LevelCritical
)

type Logger

type Logger interface {
	Name() string
	Debugf(c context.Context, format string, args ...interface{})
	Infof(c context.Context, format string, args ...interface{})
	Warningf(c context.Context, format string, args ...interface{})
	Errorf(c context.Context, format string, args ...interface{})
	Criticalf(c context.Context, format string, args ...interface{})
}

Logger interface for log provider

func NewPrinter added in v0.0.2

func NewPrinter(name string, printf func(format string, a ...any) (n int, err error)) Logger

NewPrinter creates new logger that prints to provided function Example: NewPrinter("stdout", fmt.Printf)

func NewTestingLogger added in v0.2.3

func NewTestingLogger(t *testing.T, name string) Logger

NewTestingLogger returns a logger that uses `testing.T` logger

type Message

type Message struct {
	Level  Level
	Format string
	Args   []interface{}
}

Message holds log record data

type StrongoLogger added in v0.3.0

type StrongoLogger struct {
}

func (StrongoLogger) Criticalf added in v0.3.0

func (logger StrongoLogger) Criticalf(c context.Context, format string, args ...interface{})

func (StrongoLogger) Debugf added in v0.3.0

func (logger StrongoLogger) Debugf(c context.Context, format string, args ...interface{})

func (StrongoLogger) Errorf added in v0.3.0

func (logger StrongoLogger) Errorf(c context.Context, format string, args ...interface{})

func (StrongoLogger) Infof added in v0.3.0

func (logger StrongoLogger) Infof(c context.Context, format string, args ...interface{})

func (StrongoLogger) Warningf added in v0.3.0

func (logger StrongoLogger) Warningf(c context.Context, format string, args ...interface{})

type TestLogger

type TestLogger struct {
	Messages []Message
	// contains filtered or unexported fields
}

TestLogger is a test logger

func (*TestLogger) Criticalf

func (logger *TestLogger) Criticalf(ctx context.Context, format string, args ...interface{})

Criticalf is like Debugf, but at Critical level.

func (*TestLogger) Debugf

func (logger *TestLogger) Debugf(ctx context.Context, format string, args ...interface{})

Debugf logs debug record

func (*TestLogger) Errorf

func (logger *TestLogger) Errorf(ctx context.Context, format string, args ...interface{})

Errorf is like Debugf, but at Error level.

func (*TestLogger) Infof

func (logger *TestLogger) Infof(ctx context.Context, format string, args ...interface{})

Infof is like Debugf, but at Info level.

func (*TestLogger) Name

func (logger *TestLogger) Name() string

Name returns name of the logger

func (*TestLogger) Warningf

func (logger *TestLogger) Warningf(ctx context.Context, format string, args ...interface{})

Warningf is like Debugf, but at Warning level.

Jump to

Keyboard shortcuts

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