logging

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText       = "text"
	FormatPrettyText = "prettytext"
	FormatJSON       = "json"
)
View Source
const (
	LevelDebug = zapcore.DebugLevel
	LevelInfo  = zapcore.InfoLevel
	LevelWarn  = zapcore.WarnLevel
	LevelError = zapcore.ErrorLevel
)

Variables

This section is empty.

Functions

func Any added in v0.1.1

func Any(key string, value any) zap.Field

func AttrsToFields added in v0.1.1

func AttrsToFields(args ...any) []zap.Field

func Bool added in v0.1.1

func Bool(key string, value bool) zap.Field

func Bytes added in v0.1.1

func Bytes(value int) zap.Field

func Component

func Component(value string) zap.Field

func ConnectionID

func ConnectionID(value string) zap.Field

func CorrelationFields

func CorrelationFields(ctx context.Context) []zap.Field

func Debug added in v0.1.1

func Debug(msg string, args ...any)

func DebugContext added in v0.1.1

func DebugContext(ctx context.Context, msg string, args ...any)

func Decision

func Decision(value string) zap.Field

func Dependency

func Dependency(value string) zap.Field

func DurationMS

func DurationMS(value time.Duration) zap.Field

func DurationMSFloat added in v0.1.1

func DurationMSFloat(value time.Duration) zap.Field

func Error

func Error(msg string, args ...any)

func ErrorCode

func ErrorCode(value string) zap.Field

func ErrorContext added in v0.1.1

func ErrorContext(ctx context.Context, msg string, args ...any)

func ErrorField added in v0.1.1

func ErrorField(err error) zap.Field

func ErrorMessage

func ErrorMessage(value string) zap.Field

func ForwardedFor added in v0.1.1

func ForwardedFor(value string) zap.Field

func HTTPRequestFields

func HTTPRequestFields(r *http.Request) []zap.Field

func Info added in v0.1.1

func Info(msg string, args ...any)

func InfoContext added in v0.1.1

func InfoContext(ctx context.Context, msg string, args ...any)

func InstanceID

func InstanceID(value string) zap.Field

func Int added in v0.1.1

func Int(key string, value int) zap.Field

func Int64 added in v0.1.1

func Int64(key string, value int64) zap.Field

func Kind added in v0.1.3

func Kind(value string) zap.Field

func L added in v0.1.1

func L() *zap.Logger

func LogDependencyFailure

func LogDependencyFailure(logger *zap.Logger, ctx context.Context, event DependencyFailure)

func LogPhase added in v0.1.1

func LogPhase(logger *zap.Logger, ctx context.Context, event PhaseLog)

func LogRequestComplete

func LogRequestComplete(logger *zap.Logger, ctx context.Context, event RequestComplete)

func Method

func Method(value string) zap.Field

func New

func New(cfg Config) (*zap.Logger, error)

func NewGORMLogger added in v0.1.1

func NewGORMLogger(opts GormOptions) gormlogger.Interface

func Operation

func Operation(value string) zap.Field

func Path

func Path(value string) zap.Field

func Phase

func Phase(value string) zap.Field

func ProfileID

func ProfileID(value string) zap.Field

func ProjectID

func ProjectID(value string) zap.Field

func RealIP added in v0.1.1

func RealIP(value string) zap.Field

func Reason

func Reason(value string) zap.Field

func RedactedValue

func RedactedValue() string

func RegisterContextFieldExtractor added in v0.1.1

func RegisterContextFieldExtractor(extractor ContextFieldExtractor)

func RemoteAddr

func RemoteAddr(value string) zap.Field

func RequestID

func RequestID(value string) zap.Field

func Route

func Route(value string) zap.Field

func RunID

func RunID(value string) zap.Field

func SanitizeURL

func SanitizeURL(raw string) (host string, path string)

func SanitizeURLRequest

func SanitizeURLRequest(req *http.Request) (host string, path string)

func SanitizeURLRequestURL

func SanitizeURLRequestURL(rawURL *url.URL) (host string, path string)

func ServerID

func ServerID(value string) zap.Field

func Service

func Service(value string) zap.Field

func SetDefault added in v0.1.1

func SetDefault(logger *zap.Logger)

func SpanID

func SpanID(value string) zap.Field

func Status

func Status(value int) zap.Field

func String added in v0.1.1

func String(key string, value string) zap.Field

func TenantID

func TenantID(value string) zap.Field

func TokenPresent

func TokenPresent(token string) bool

func TraceID

func TraceID(value string) zap.Field

func TraceSampled added in v0.1.1

func TraceSampled(value bool) zap.Field

func URLHost

func URLHost(value string) zap.Field

func URLPath

func URLPath(value string) zap.Field

func UserAgent

func UserAgent(value string) zap.Field

func UserID

func UserID(value string) zap.Field

func Warn added in v0.1.1

func Warn(msg string, args ...any)

func WarnContext added in v0.1.1

func WarnContext(ctx context.Context, msg string, args ...any)

func WithInstanceID

func WithInstanceID(ctx context.Context, value string) context.Context

func WithProjectID

func WithProjectID(ctx context.Context, value string) context.Context

func WithRequestID

func WithRequestID(ctx context.Context, value string) context.Context

func WithRunID

func WithRunID(ctx context.Context, value string) context.Context

func WithServerID

func WithServerID(ctx context.Context, value string) context.Context

func WithTenantID

func WithTenantID(ctx context.Context, value string) context.Context

func WithUserID

func WithUserID(ctx context.Context, value string) context.Context

func WithWorkflowID

func WithWorkflowID(ctx context.Context, value string) context.Context

func WorkflowID

func WorkflowID(value string) zap.Field

Types

type Config

type Config struct {
	Service string
	Format  string
	Level   string

	Output io.Writer

	AddCaller       bool
	DisableCaller   bool
	StacktraceLevel string
}

Config controls shared logger construction for Go backend services.

type ContextFieldExtractor added in v0.1.1

type ContextFieldExtractor func(context.Context) []zap.Field

type DependencyFailure

type DependencyFailure struct {
	Message    string
	Dependency string
	Operation  string
	Activity   string
	Method     string
	URLHost    string
	URLPath    string
	Status     int
	Duration   time.Duration
	ErrorCode  string
	Err        error
	Fields     []any
}

func ObserveHTTPDependency

func ObserveHTTPDependency(dependency, operation, activity string, req *http.Request, status int, duration time.Duration, err error) DependencyFailure

type GormOptions added in v0.1.1

type GormOptions struct {
	SlowThreshold time.Duration
}

type Level added in v0.1.1

type Level = zapcore.Level

type PhaseLog added in v0.1.1

type PhaseLog struct {
	Message string
	Phase   string
	Level   Level
	Fields  []any
}

type RequestComplete

type RequestComplete struct {
	Service string
	Method  string
	Route   string
	Status  int

	Duration     time.Duration
	ErrorCode    string
	ErrorMessage string
	Dependency   string

	Fields []any
}

Jump to

Keyboard shortcuts

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