log

package module
v3.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 12 Imported by: 6

README

logs-go

CircleCI codecov

Wrapper for uber zap logger tuned to work with configuration and sentry hook.

Usage

Initiate new logger filled with struct that implements LogsConfigInterface and use it as common zap logger

package main

import (
	"os"

	cfgstructs "github.com/spacetab-io/configuration-structs-go/v2"
	log "github.com/spacetab-io/logs-go/v3"
)

func main() {
	conf := &cfgstructs.Logs{
		Level:   "debug",
		Format:  "text",
		Colored: true,
		Caller:  cfgstructs.CallerConfig{Show: true, SkipFrames: 1},
		Sentry: &cfgstructs.SentryConfig{
			Enable: true,
			Debug:  true,
			DSN:    os.Getenv("SENTRY_DSN"),
		},
	}

	logger, err := log.Init(conf, "test", "service", "v3.0.0", os.Stdout)
	if err != nil {
		panic(err)
	}

	logger.Warn().Msg("log some warning")
}

Licence

The software is provided under MIT Licence.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyOutput = errors.New("log output is not defined")

Functions

This section is empty.

Types

type Event

type Event struct {
	*Logger
	// contains filtered or unexported fields
}

func (*Event) Bytes

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

func (*Event) Dur

func (e *Event) Dur(key string, value time.Duration) *Event

func (*Event) Err

func (e *Event) Err(err error) *Event

func (*Event) Int

func (e *Event) Int(key string, value int) *Event

func (*Event) Int32

func (e *Event) Int32(key string, value int32) *Event

func (*Event) Int32p

func (e *Event) Int32p(key string, value *int32) *Event

func (*Event) Int64

func (e *Event) Int64(key string, value int64) *Event

func (*Event) Int64p

func (e *Event) Int64p(key string, value *int64) *Event

func (*Event) Interface

func (e *Event) Interface(key string, val interface{}) *Event

func (*Event) Interfaces

func (e *Event) Interfaces(key string, vals ...interface{}) *Event

func (*Event) Intp

func (e *Event) Intp(key string, value *int) *Event

func (Event) Msg

func (e Event) Msg(msg string)

func (*Event) Msgf

func (e *Event) Msgf(format string, params ...interface{})

func (*Event) Send

func (e *Event) Send()

func (*Event) SetLogLevel

func (e *Event) SetLogLevel(lvl zapcore.Level) *Event

func (*Event) Str

func (e *Event) Str(key, value string) *Event

func (*Event) Strs

func (e *Event) Strs(key string, values []string) *Event

func (*Event) Uint

func (e *Event) Uint(key string, value uint) *Event

func (*Event) Uint32

func (e *Event) Uint32(key string, value uint32) *Event

func (*Event) Uint32p

func (e *Event) Uint32p(key string, value *uint32) *Event

func (*Event) Uint64p

func (e *Event) Uint64p(key string, value *uint64) *Event

func (*Event) Uintp

func (e *Event) Uintp(key string, value *uint) *Event

func (*Event) Unt64

func (e *Event) Unt64(key string, value uint64) *Event

type FHLogger

type FHLogger struct {
	Logger
}

func (FHLogger) Printf

func (fhl FHLogger) Printf(format string, v ...interface{})

type GooseLogger

type GooseLogger struct {
	Logger
}

func NewGooseLogger

func NewGooseLogger(logger Logger) GooseLogger

func (GooseLogger) Fatal

func (l GooseLogger) Fatal(v ...interface{})

func (GooseLogger) Fatalf

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

func (GooseLogger) Print

func (l GooseLogger) Print(v ...interface{})

func (GooseLogger) Printf

func (l GooseLogger) Printf(format string, v ...interface{})

func (GooseLogger) Println

func (l GooseLogger) Println(v ...interface{})

type KafkaLogger

type KafkaLogger struct {
	Logger
}

func NewKafkaLogger

func NewKafkaLogger(l Logger) KafkaLogger

func (KafkaLogger) Printf

func (kl KafkaLogger) Printf(format string, v ...interface{})

type Logger

type Logger struct {
	*zap.Logger
	Level zapcore.Level
	// contains filtered or unexported fields
}

func Init

func Init(cfg contracts.LogsCfgInterface, stage string, serviceAlias string, serviceVersion string, w io.Writer) (Logger, error)

func (Logger) DPanic

func (l Logger) DPanic() *Event

func (Logger) Debug

func (l Logger) Debug() *Event

func (Logger) Error

func (l Logger) Error() *Event

func (Logger) Fatal

func (l Logger) Fatal() *Event

func (Logger) ForLogLevel

func (l Logger) ForLogLevel(lvl zapcore.Level) *Event

func (Logger) Info

func (l Logger) Info() *Event

func (Logger) LogEvent

func (l Logger) LogEvent() *Event

func (Logger) Panic

func (l Logger) Panic() *Event

func (Logger) Printf

func (l Logger) Printf(format string, v ...interface{})

func (Logger) Warn

func (l Logger) Warn() *Event

type NSQLogger

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

func NewNSQLogger

func NewNSQLogger(logger Logger) NSQLogger

func (NSQLogger) LogLevel

func (nl NSQLogger) LogLevel() int

func (NSQLogger) Output

func (nl NSQLogger) Output(calldepth int, s string) error

type SentryEventIdentityModifier

type SentryEventIdentityModifier struct{}

SentryEventIdentityModifier is a sentry event modifier that simply passes through the event.

func (*SentryEventIdentityModifier) ApplyToEvent

func (m *SentryEventIdentityModifier) ApplyToEvent(event *sentry.Event, hint *sentry.EventHint) *sentry.Event

ApplyToEvent simply returns the event (ignoring the hint).

Jump to

Keyboard shortcuts

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