tracer

package module
v0.0.0-...-57f4d5d Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 3 Imported by: 1

README

Tracer is a logging package designed for event logging with a focus on sensitive data. It allows applications to log events that need to be archived securely, ensuring that sensitive information is not stored in default logs. The package complements existing logging solutions by providing an additional layer of control over which events and data are logged and archived, without exposing sensitive details unnecessarily.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int
const (
	Trace Level = 1 << iota
	Info
	Debug
	Warn
	Error
)
const All Level = Trace | Info | Debug | Warn | Error

type NopWriter

type NopWriter struct {
	io.Writer
}

func (NopWriter) OnClose

func (NopWriter) OnClose() error

type Tracer

type Tracer interface {
	NeedNoErr(err error) string
	SetValue(name string, value string)
	Write(b []byte) (n int, err error)
	WriteString(s string)
	Writef(s string, args ...interface{})
	WriteLine(s string)
	WriteLinef(s string, args ...interface{})
	Trace(message string, args ...interface{})
	Debug(message string, args ...interface{})
	Info(message string, args ...interface{})
	Error(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Fatal(message string, args ...interface{})
	Close() error
}

func New

func New(level Level, writer Writer) Tracer

New create new instance of tracer @level specify the warning levels you want to save, e.g. All for everyone or selected: Info|Error @writer logs will be saved here

func NewSimple

func NewSimple(level Level, handler func([]byte)) Tracer

NewSimple e.g. for using simple writing example using with slog:

NewSimple(All, func(bytes []byte) {
	slog.Default().Info(string(bytes))
})

func NewWithoutOnCloser

func NewWithoutOnCloser(level Level, writer io.Writer) Tracer

type Writer

type Writer interface {
	Write(b []byte) (n int, err error)
	OnClose() error
}

Jump to

Keyboard shortcuts

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