wool

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 14 Imported by: 7

README

Observability

Wool

Wrapper Over Open-Telemetry is accurate and has a meaningful acronym. Yarn, fiber, we are in the "context" space.

Goal of this package is to provide a Canvas that satisfies the following requirements:

Requirement:

  • context.Context based
  • opentelemetry support with flexible backend
  • logger support as Events (where opentelemetry is going) with flexible backend

Documentation

Index

Constants

View Source
const CodePathKey = "codepath"
View Source
const KeyInContext = ContextKey("provider")
View Source
const LogEvent = "log"

Variables

This section is empty.

Functions

func IsDebug added in v0.0.60

func IsDebug() bool

func SetGlobalLogLevel added in v0.0.65

func SetGlobalLogLevel(loglevel Loglevel)

func TypeOf added in v0.0.55

func TypeOf[T any]() string

func WithTelemetry

func WithTelemetry() bool

Types

type CodePath added in v0.0.55

type CodePath struct {
	Method string      `json:"method"`
	Fields []*LogField `json:"fields"`
}

type CodeReference added in v0.0.60

type CodeReference struct {
	Line int    `json:"line"`
	File string `json:"file"`
}

func (*CodeReference) String added in v0.0.71

func (c *CodeReference) String() string

type Console added in v0.0.57

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

func (Console) Process added in v0.0.57

func (c Console) Process(msg *Log)

type ContextKey

type ContextKey string

type Identifier added in v0.0.55

type Identifier struct {
	Kind   string `json:"kind"`
	Unique string `json:"unique"`
}

func System added in v0.0.67

func System() *Identifier

func (*Identifier) IsSystem added in v0.0.67

func (identifier *Identifier) IsSystem() bool

type Log

type Log struct {
	Level   Loglevel    `json:"level"`
	Header  string      `json:"header"`
	Message string      `json:"message"`
	Fields  []*LogField `json:"fields"`
}

func LogError added in v0.0.67

func LogError(err error, msg string, fields ...*LogField) *Log

func LogTrace added in v0.0.67

func LogTrace(msg string, fields ...*LogField) *Log

func (*Log) AtLevel

func (l *Log) AtLevel(debug Loglevel) *Log

func (*Log) Event

func (l *Log) Event() trace.SpanStartEventOption

func (*Log) String added in v0.0.65

func (l *Log) String() string

String display a log message into this format (level) (this) message [key=value, key=value]

type LogField

type LogField struct {
	Key   string   `json:"key"`
	Level Loglevel `json:"level"`
	Value any      `json:"value"`
}

LogField is a key value pair with a log level A Field is shown only if the log level is equal or higher than the log level of the log

func DirField added in v0.0.55

func DirField(dir string) *LogField

func ErrField added in v0.0.55

func ErrField(err error) *LogField

func Field

func Field(key string, value any) *LogField

Field with default level

func FileField added in v0.0.55

func FileField(file string) *LogField

func FocusField added in v0.0.69

func FocusField() *LogField

func GenericField added in v0.0.55

func GenericField[T any]() *LogField

func InField added in v0.0.81

func InField(s string) *LogField

func NameField added in v0.0.55

func NameField(name string) *LogField

func NullableField added in v0.0.81

func NullableField[T any](key string, value T) *LogField

func PathField added in v0.0.55

func PathField(dir string) *LogField

func PointerField added in v0.0.57

func PointerField[T any](override *T) *LogField

func RequestField added in v0.0.55

func RequestField(req any) *LogField

func ResponseField added in v0.0.67

func ResponseField(req any) *LogField

func SliceCountField added in v0.0.57

func SliceCountField[T any](slice []T) *LogField

func StatusFailed added in v0.0.55

func StatusFailed() *LogField

func StatusOK added in v0.0.55

func StatusOK() *LogField

func ThisField added in v0.0.55

func ThisField(this Unique) *LogField

func Writer added in v0.0.67

func Writer() *LogField

func (*LogField) Debug added in v0.0.67

func (f *LogField) Debug() *LogField

func (*LogField) Error added in v0.0.67

func (f *LogField) Error() *LogField

func (*LogField) String added in v0.0.57

func (f *LogField) String() string

func (*LogField) Trace added in v0.0.67

func (f *LogField) Trace() *LogField

type LogProcessor added in v0.0.55

type LogProcessor interface {
	Process(msg *Log)
}

type LogProcessorWithSource added in v0.0.55

type LogProcessorWithSource interface {
	ProcessWithSource(msg *Log, source *Identifier)
}

type Loglevel

type Loglevel int
const (
	DEFAULT Loglevel = iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
	FOCUS
	FORWARD
)

func GlobalLogLevel added in v0.0.65

func GlobalLogLevel() Loglevel

type Provider added in v0.0.55

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

Provider keeping track

func New

func New(ctx context.Context, r *Resource) *Provider

func (*Provider) Done added in v0.0.55

func (provider *Provider) Done()

func (*Provider) Get added in v0.0.55

func (provider *Provider) Get(ctx context.Context) *Wool

func (*Provider) Inject added in v0.0.71

func (provider *Provider) Inject(ctx context.Context) context.Context

func (*Provider) WithConsole added in v0.0.69

func (provider *Provider) WithConsole(lvl Loglevel) *Provider

func (*Provider) WithLogger added in v0.0.55

func (provider *Provider) WithLogger(l LogProcessor) *Provider

type Resource added in v0.0.55

type Resource struct {
	Resource *resource.Resource
	*Identifier
}

type Unique added in v0.0.55

type Unique interface {
	Unique() string
}

type Wool

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

func Get

func Get(ctx context.Context) *Wool

func (*Wool) Catch added in v0.0.55

func (w *Wool) Catch()

Catch recovers from a panic and logs the error

func (*Wool) Close added in v0.0.55

func (w *Wool) Close()

func (*Wool) Debug added in v0.0.55

func (w *Wool) Debug(msg string, fields ...*LogField)

func (*Wool) Error added in v0.0.55

func (w *Wool) Error(msg string, fields ...*LogField)

func (*Wool) Fatal added in v0.0.55

func (w *Wool) Fatal(msg string, fields ...*LogField)

func (*Wool) Focus added in v0.0.69

func (w *Wool) Focus(msg string, fields ...*LogField)

func (*Wool) Forward added in v0.0.71

func (w *Wool) Forward(p []byte) (n int, err error)

func (*Wool) In added in v0.0.55

func (w *Wool) In(method string, fields ...*LogField) *Wool

func (*Wool) Info added in v0.0.55

func (w *Wool) Info(msg string, fields ...*LogField)

func (*Wool) Inject added in v0.0.67

func (w *Wool) Inject(ctx context.Context) context.Context

func (*Wool) Name added in v0.0.55

func (w *Wool) Name() string

func (*Wool) NewError added in v0.0.55

func (w *Wool) NewError(format string, args ...any) error

func (*Wool) Source added in v0.0.67

func (w *Wool) Source() *Identifier

func (*Wool) StackTrace added in v0.0.55

func (w *Wool) StackTrace() []CodePath

func (*Wool) Trace added in v0.0.55

func (w *Wool) Trace(msg string, fields ...*LogField)

func (*Wool) Warn added in v0.0.55

func (w *Wool) Warn(msg string, fields ...*LogField)

func (*Wool) With added in v0.0.60

func (w *Wool) With(fields ...*LogField) *Wool

func (*Wool) WithLogger added in v0.0.55

func (w *Wool) WithLogger(l LogProcessor) *Wool

func (*Wool) WithLoglevel added in v0.0.87

func (w *Wool) WithLoglevel(level Loglevel)

func (*Wool) Wrap added in v0.0.55

func (w *Wool) Wrap(err error) error

func (*Wool) Wrapf added in v0.0.55

func (w *Wool) Wrapf(err error, msg string, args ...any) error

func (*Wool) Write added in v0.0.67

func (w *Wool) Write(p []byte) (n int, err error)

Writer implements the io.Writer interface

Directories

Path Synopsis
adapters
log

Jump to

Keyboard shortcuts

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