tracelogix

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tracelogix provides a service for collecting and managing contextual information to correlate related logs throughout the lifecycle of a request or operation. This package is designed to be integrated as a service within your application, enabling you to log events with contextual data seamlessly during context passing.

The primary goal is to enhance log tracing and debugging by maintaining context-specific data, making it easier to understand the flow and state of an application at various points.

Index

Constants

View Source
const LoggerMetadataContextKey loggerContextKey = "traceLogMetadataContextKey"

LoggerMetadataContextKey that must be utilized for metadata sharing inside context.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogAdapter

type LogAdapter interface {
	// LogAdaptersWriter for log events.
	LogAdaptersWriter(ctx context.Context, lvl LogAdapterLevel, msg string, meta *MetadataFields)
}

LogAdapter that handles writing logs.

type LogAdapterLevel

type LogAdapterLevel int8

LogAdapterLevel verbosity level type.

const (
	LogAdapterFatal LogAdapterLevel = iota
	LogAdapterError
	LogAdapterWarn
	LogAdapterInfo
	LogAdapterDebug
)

type MetadataFields

type MetadataFields map[string]any

MetadataFields that must be logged with message.

type TraceLog

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

TraceLog is a structured logger designed for tracing app-level events and activities, in an informative and standardized way.

The primary use of TraceLog is to capture and present logs in a manner that aids debugging, performance monitoring.

func NewTraceLog

func NewTraceLog(adapter LogAdapter) *TraceLog

NewTraceLog constructor.

func (*TraceLog) Log

func (tl *TraceLog) Log(srcCtx context.Context, severityLvl LogAdapterLevel, logMessage string, metadata *MetadataFields)

Log information with intercepted metadata from request.

func (*TraceLog) SetContextMetadata

func (tl *TraceLog) SetContextMetadata(srcCtx context.Context, newMetadata MetadataFields) context.Context

SetContextMetadata allows preallocate request metadata for TraceLog. Useful to expand log information across application level.

type TraceLogService

type TraceLogService interface {
	// SetContextMetadata allows preallocate request metadata for TraceLog.
	// Useful to expand log information across application level.
	SetContextMetadata(reqCtx context.Context, reqLogMetadataFields MetadataFields) context.Context
	// Log information with intercepted metadata from request.
	Log(sourceCtx context.Context, logSeverity LogAdapterLevel, logMessage string, logMeta *MetadataFields)
}

TraceLogService interface.

Jump to

Keyboard shortcuts

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