Documentation
¶
Index ¶
- Variables
- func AddCustomProfile(name, description string, factory func() core.LogEventFilter) error
- func AddCustomProfileWithVersion(name, description, version string, deprecated bool, replacement string, ...) error
- func Build(opts ...Option) (*logger, error)
- func DisableSamplingDebug()
- func EnableSamplingDebug()
- func ExtractTypeName[T any](options TypeNameOptions) string
- func ExtractTypeNameWithCacheKey[T any](options TypeNameOptions, cacheKeyPrefix string) string
- func ForType[T any](logger core.Logger) core.Logger
- func ForTypeWithCacheKey[T any](logger core.Logger, cacheKeyPrefix string) core.Logger
- func FreezeProfiles()
- func GetAvailableProfileDescriptions() map[string]string
- func GetAvailableProfiles() []string
- func GetProfileDescription(profileName string) (string, bool)
- func GetProfileVersion(profileName string) (string, bool)
- func GetProfileVersions(profileName string) []string
- func GetTypeNameSimple[T any]() string
- func GetTypeNameWithPackage[T any]() string
- func IsProfileDeprecated(profileName string) (bool, string)
- func IsProfileRegistryFrozen() bool
- func IsSamplingDebugEnabled() bool
- func New(opts ...Option) *logger
- func NewSlogLogger(options ...Option) *slog.Logger
- func PushProperty(ctx context.Context, name string, value any) context.Context
- func RegisterCustomProfiles(customProfiles map[string]SamplingProfile) error
- func ResetTypeNameCache()
- func Route(name string) *sinks.RouteBuilder
- func SetMigrationPolicy(policy MigrationPolicy) error
- func WarmupSamplingBackoff(keys []string, defaultFactor float64)
- func WarmupSamplingGroups(groupNames []string)
- func WithControlledLevel(initialLevel core.LogEventLevel) (Option, *LoggingLevelSwitch)
- func WithSeqLevelControl(serverURL string, options SeqLevelControllerOptions, ...) (Option, *LoggingLevelSwitch, *SeqLevelController)
- type AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilter(targetEventsPerSecond uint64) *AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilterPresetDefaults(targetEventsPerSecond uint64, preset DampeningPreset) *AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilterWithDampening(targetEventsPerSecond uint64, minRate, maxRate float64, ...) *AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilterWithHysteresis(targetEventsPerSecond uint64, minRate, maxRate float64, ...) *AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilterWithOptions(targetEventsPerSecond uint64, minRate, maxRate float64, ...) *AdaptiveSamplingFilter
- func NewAdaptiveSamplingFilterWithPreset(targetEventsPerSecond uint64, preset DampeningPreset, minRate, maxRate float64) *AdaptiveSamplingFilter
- type AdaptiveSamplingStats
- type DampeningConfig
- type DampeningPreset
- type LogBuilder
- type LoggerG
- type LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) Debug() *LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) Error() *LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) Fatal() *LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) Information() *LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) IsEnabled(level core.LogEventLevel) bool
- func (ls *LoggingLevelSwitch) Level() core.LogEventLevel
- func (ls *LoggingLevelSwitch) SetLevel(level core.LogEventLevel)
- func (ls *LoggingLevelSwitch) Verbose() *LoggingLevelSwitch
- func (ls *LoggingLevelSwitch) Warning() *LoggingLevelSwitch
- type MigrationConsent
- type MigrationPolicy
- type Option
- func Debug() Option
- func Error() Option
- func Information() Option
- func Verbose() Option
- func Warning() Option
- func WithAutoSourceContext() Option
- func WithCallers(skip int) Option
- func WithCallersInfo() Option
- func WithCapturer(capturer core.Capturer) Option
- func WithCapturing() Option
- func WithCapturingDepth(maxDepth int) Option
- func WithCommonEnvironment() Option
- func WithConditional(predicate func(*core.LogEvent) bool, sink core.LogEventSink) Option
- func WithConsole() Option
- func WithConsoleProperties() Option
- func WithConsoleTemplate(template string) Option
- func WithConsoleTemplateAndTheme(template string, theme *sinks.ConsoleTheme) Option
- func WithConsoleTheme(theme *sinks.ConsoleTheme) Option
- func WithContextDeadlineWarning(threshold time.Duration, opts ...enrichers.DeadlineOption) Option
- func WithCorrelationId(correlationId string) Option
- func WithCustomCapturing(maxDepth, maxStringLength, maxCollectionCount int) Option
- func WithDeadlineOptions(opts ...enrichers.DeadlineOption) Option
- func WithDeadlinePercentageOnly(percent float64, opts ...enrichers.DeadlineOption) Option
- func WithDeadlinePercentageThreshold(threshold time.Duration, percent float64, opts ...enrichers.DeadlineOption) Option
- func WithDefaultSampling(n uint64) Option
- func WithDurableBuffer(wrapped core.LogEventSink, bufferPath string) Option
- func WithDurableBufferAdvanced(wrapped core.LogEventSink, options sinks.DurableOptions) Option
- func WithDurableElasticsearch(url, bufferPath string) Option
- func WithDurableSeq(serverURL, bufferPath string) Option
- func WithDurableSplunk(url, token, bufferPath string) Option
- func WithDynamicLevel(levelSwitch *LoggingLevelSwitch) Option
- func WithElasticsearch(url string) Option
- func WithElasticsearchAPIKey(url, apiKey string) Option
- func WithElasticsearchAdvanced(url string, opts ...sinks.ElasticsearchOption) Option
- func WithElasticsearchBasicAuth(url, username, password string) Option
- func WithEnricher(enricher core.LogEventEnricher) Option
- func WithEnvironment(variableName, propertyName string) Option
- func WithEnvironmentVariables(variables ...string) Option
- func WithExcludeFilter(predicate func(*core.LogEvent) bool) Option
- func WithFile(path string) Option
- func WithFileTemplate(path string, template string) Option
- func WithFilter(filter core.LogEventFilter) Option
- func WithHashSampling(propertyName string, rate float32) Option
- func WithLevelFilter(minimumLevel core.LogEventLevel) Option
- func WithLevelSwitch(levelSwitch *LoggingLevelSwitch) Option
- func WithMachineName() Option
- func WithMinimumLevel(level core.LogEventLevel) Option
- func WithMinimumLevelOverrides(defaultLevel core.LogEventLevel, overrides map[string]core.LogEventLevel) Option
- func WithProcess() Option
- func WithProcessInfo() Option
- func WithProperties(properties map[string]any) Option
- func WithProperty(name string, value any) Option
- func WithPropertyFilter(propertyName string, expectedValue any) Option
- func WithRateLimit(maxEvents int, windowNanos int64) Option
- func WithRouter(routes ...sinks.Route) Option
- func WithRouterDefault(mode sinks.RoutingMode, defaultSink core.LogEventSink, routes ...sinks.Route) Option
- func WithRouterMode(mode sinks.RoutingMode, routes ...sinks.Route) Option
- func WithSampling(rate float32) Option
- func WithSamplingMemoryLimit(maxKeys int) Option
- func WithSamplingPolicy(policy core.SamplingPolicy) Option
- func WithSeq(serverURL string) Option
- func WithSeqAPIKey(serverURL, apiKey string) Option
- func WithSeqAdvanced(serverURL string, opts ...sinks.SeqOption) Option
- func WithSink(sink core.LogEventSink) Option
- func WithSourceContext(sourceContext string) Option
- func WithSplunk(url, token string) Option
- func WithSplunkAdvanced(url, token string, opts ...sinks.SplunkOption) Option
- func WithThreadId() Option
- func WithTimestamp() Option
- type Repository
- type SamplingConfigBuilder
- func (s *SamplingConfigBuilder) AsOption() Option
- func (s *SamplingConfigBuilder) Backoff(key string, factor float64) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) Build() Option
- func (s *SamplingConfigBuilder) CombineAND() Option
- func (s *SamplingConfigBuilder) CombineOR() Option
- func (s *SamplingConfigBuilder) Duration(d time.Duration) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) Every(n uint64) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) First(n uint64) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) Group(name string, n uint64) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) Rate(rate float32) *SamplingConfigBuilder
- func (s *SamplingConfigBuilder) When(predicate func() bool, n uint64) *SamplingConfigBuilder
- type SamplingProfile
- type SeqLevelController
- type SeqLevelControllerBuilder
- func (b *SeqLevelControllerBuilder) Build() (Option, *LoggingLevelSwitch, *SeqLevelController)
- func (b *SeqLevelControllerBuilder) WithCheckInterval(interval time.Duration) *SeqLevelControllerBuilder
- func (b *SeqLevelControllerBuilder) WithErrorHandler(onError func(error)) *SeqLevelControllerBuilder
- func (b *SeqLevelControllerBuilder) WithInitialCheck(initialCheck bool) *SeqLevelControllerBuilder
- func (b *SeqLevelControllerBuilder) WithLevelSwitch(levelSwitch *LoggingLevelSwitch) *SeqLevelControllerBuilder
- func (b *SeqLevelControllerBuilder) WithSeqAPIKey(apiKey string) *SeqLevelControllerBuilder
- type SeqLevelControllerOptions
- type StructuredLogger
- type TypeNameCacheStats
- type TypeNameOptions
- type TypedLogger
- func (l *TypedLogger[T]) DebugT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) ErrorT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) FatalT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) ForContextT(propertyName string, value T) LoggerG[T]
- func (l *TypedLogger[T]) InfoT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) InformationT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) VerboseT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) WarnT(messageTemplate string, value T, args ...any)
- func (l *TypedLogger[T]) WarningT(messageTemplate string, value T, args ...any)
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
var DefaultTypeNameOptions = TypeNameOptions{ IncludePackage: false, PackageDepth: 1, Prefix: "", Suffix: "", SimplifyAnonymous: false, WarnOnUnknown: true, }
DefaultTypeNameOptions provides sensible defaults for type name extraction.
Functions ¶
func AddCustomProfile ¶ added in v0.10.0
func AddCustomProfile(name, description string, factory func() core.LogEventFilter) error
AddCustomProfile allows users to add their own sampling profiles (before freezing)
func AddCustomProfileWithVersion ¶ added in v0.10.0
func AddCustomProfileWithVersion(name, description, version string, deprecated bool, replacement string, factory func() core.LogEventFilter) error
AddCustomProfileWithVersion allows users to add versioned sampling profiles (before freezing)
func Build ¶ added in v0.2.0
Build creates a new logger with the specified options. Returns an error if any option fails during configuration.
func DisableSamplingDebug ¶ added in v0.10.0
func DisableSamplingDebug()
DisableSamplingDebug disables logging of sampling decisions.
func EnableSamplingDebug ¶ added in v0.10.0
func EnableSamplingDebug()
EnableSamplingDebug enables logging of sampling decisions to selflog for debugging. This helps understand why certain events are being sampled or skipped. The debug output includes the template, the sampling decision, and the filter that made it.
func ExtractTypeName ¶ added in v0.3.0
func ExtractTypeName[T any](options TypeNameOptions) string
ExtractTypeName extracts a string representation of the type T using the provided options. This is the exported version of extractTypeName for creating custom loggers.
func ExtractTypeNameWithCacheKey ¶ added in v0.3.0
func ExtractTypeNameWithCacheKey[T any](options TypeNameOptions, cacheKeyPrefix string) string
ExtractTypeNameWithCacheKey extracts a string representation of the type T using the provided options and a custom cache key prefix for multi-tenant scenarios. The cacheKeyPrefix allows for separate cache namespaces, useful in multi-tenant applications where different tenants might have different type naming requirements.
Example usage:
tenantPrefix := fmt.Sprintf("tenant:%s", tenantID)
name := ExtractTypeNameWithCacheKey[User](options, tenantPrefix)
logger := baseLogger.ForContext("SourceContext", name)
func ForType ¶ added in v0.3.0
ForType creates a logger with SourceContext automatically set from the type name. The type name is extracted using reflection and provides a convenient way to categorize logs by the types they relate to.
By default, only the type name is used (without package). For example:
type User struct { Name string }
ForType[User](logger).Information("User created") // SourceContext: "User"
ForType[*User](logger).Information("User updated") // SourceContext: "User" (pointer dereferenced)
This is equivalent to:
logger.ForContext("SourceContext", "User").Information("User created")
But more convenient and less error-prone for type-specific logging.
Performance: Uses reflection for type name extraction, which incurs a small performance overhead (~7%) compared to manual ForSourceContext. For high-performance scenarios, consider using ForSourceContext with string literals.
Edge Cases:
- Anonymous structs: Return their full definition (e.g., "struct { Name string }")
- Interfaces: Return "Unknown" as they have no concrete type name
- Generic types: Include type parameters (e.g., "GenericType[string]")
- Built-in types: Return their standard names (e.g., "string", "int", "[]string")
- Function/channel types: Return their signature (e.g., "func(string) error", "chan string")
For more control over type name formatting, use extractTypeName with custom TypeNameOptions. See createCustomLogger in examples/fortype/main.go for a pattern to create custom loggers with TypeNameOptions for specific naming requirements.
func ForTypeWithCacheKey ¶ added in v0.3.0
ForTypeWithCacheKey creates a logger with SourceContext automatically set from the type name using a custom cache key prefix. This is useful in multi-tenant scenarios where different tenants might require separate cache namespaces.
Example usage:
tenantPrefix := fmt.Sprintf("tenant:%s", tenantID)
userLogger := ForTypeWithCacheKey[User](logger, tenantPrefix)
userLogger.Information("User operation") // SourceContext: "User" (cached per tenant)
func FreezeProfiles ¶ added in v0.10.0
func FreezeProfiles()
FreezeProfiles makes the profile registry immutable, preventing further modifications. This should be called after all custom profiles have been registered, typically during application initialization to ensure thread-safety and prevent accidental modifications.
func GetAvailableProfileDescriptions ¶ added in v0.10.0
GetAvailableProfileDescriptions returns a map of profile names to their descriptions. This is useful for runtime configuration and discovery of available profiles.
func GetAvailableProfiles ¶ added in v0.10.0
func GetAvailableProfiles() []string
GetAvailableProfiles returns a list of available sampling profiles
func GetProfileDescription ¶ added in v0.10.0
GetProfileDescription returns the description for a given profile
func GetProfileVersion ¶ added in v0.10.0
GetProfileVersion returns the version of the currently active profile
func GetProfileVersions ¶ added in v0.10.0
GetProfileVersions returns all available versions for a profile
func GetTypeNameSimple ¶ added in v0.3.0
GetTypeNameSimple is the exported version of getTypeNameSimple for testing and benchmarking.
func GetTypeNameWithPackage ¶ added in v0.3.0
GetTypeNameWithPackage is the exported version of getTypeNameWithPackage for testing and benchmarking.
func IsProfileDeprecated ¶ added in v0.10.0
IsProfileDeprecated checks if a profile is marked as deprecated
func IsProfileRegistryFrozen ¶ added in v0.10.0
func IsProfileRegistryFrozen() bool
IsProfileRegistryFrozen returns true if the profile registry has been frozen.
func IsSamplingDebugEnabled ¶ added in v0.10.0
func IsSamplingDebugEnabled() bool
IsSamplingDebugEnabled returns whether sampling debug logging is enabled.
func New ¶
func New(opts ...Option) *logger
New creates a new logger with the specified options. If any option returns an error during configuration, New will panic. Use Build() for non-panicking initialization.
func NewSlogLogger ¶
NewSlogLogger creates a new slog.Logger backed by mtlog
func PushProperty ¶ added in v0.3.0
PushProperty adds a property to the context that will be included in all log events created from loggers using this context. Properties are inherited - if a context already has properties, the new context will include both the existing and new properties.
Properties set via PushProperty have the lowest precedence and are overridden by ForContext properties and event-specific properties.
Thread Safety: This function is thread-safe. It creates a new context value with a copy of the properties map, ensuring immutability. Multiple goroutines can safely call PushProperty on the same context, and each will receive its own independent context.
Example:
ctx := context.Background()
ctx = mtlog.PushProperty(ctx, "UserId", 123)
ctx = mtlog.PushProperty(ctx, "TenantId", "acme-corp")
// Both UserId and TenantId will be included in this log
logger.WithContext(ctx).Information("Processing user request")
// Properties can be overridden at more specific scopes
logger.WithContext(ctx).ForContext("UserId", 456).Information("Override test")
// Results in UserId=456 (ForContext overrides PushProperty)
func RegisterCustomProfiles ¶ added in v0.10.0
func RegisterCustomProfiles(customProfiles map[string]SamplingProfile) error
RegisterCustomProfiles allows bulk registration of custom profiles before freezing. Returns an error if any profile fails to register or if the registry is already frozen.
func ResetTypeNameCache ¶ added in v0.3.0
func ResetTypeNameCache()
ResetTypeNameCache clears the type name cache and statistics. Useful for testing and benchmarking.
func Route ¶ added in v0.10.0
func Route(name string) *sinks.RouteBuilder
Route creates a new route builder for fluent route configuration.
func SetMigrationPolicy ¶ added in v0.10.0
func SetMigrationPolicy(policy MigrationPolicy) error
SetMigrationPolicy updates the global migration policy
func WarmupSamplingBackoff ¶ added in v0.10.0
WarmupSamplingBackoff pre-populates the backoff sampling cache with common keys. This helps avoid cold-start allocation spikes in high-traffic applications.
func WarmupSamplingGroups ¶ added in v0.10.0
func WarmupSamplingGroups(groupNames []string)
WarmupSamplingGroups pre-populates the sampling group cache with common group names. This helps avoid cold-start allocation spikes in high-traffic applications.
func WithControlledLevel ¶
func WithControlledLevel(initialLevel core.LogEventLevel) (Option, *LoggingLevelSwitch)
WithControlledLevel creates a level switch and applies it to the logger. Returns both the option and the level switch for external control.
func WithSeqLevelControl ¶
func WithSeqLevelControl(serverURL string, options SeqLevelControllerOptions, seqOptions ...sinks.SeqOption) (Option, *LoggingLevelSwitch, *SeqLevelController)
WithSeqLevelControl creates a logger with Seq-controlled dynamic level adjustment. This convenience function sets up both a Seq sink and automatic level control.
Types ¶
type AdaptiveSamplingFilter ¶ added in v0.10.0
type AdaptiveSamplingFilter struct {
// contains filtered or unexported fields
}
AdaptiveSamplingFilter adjusts sampling rates based on system load or event frequency. Features hysteresis, dampening, and configurable aggressiveness for stable production use.
func NewAdaptiveSamplingFilter ¶ added in v0.10.0
func NewAdaptiveSamplingFilter(targetEventsPerSecond uint64) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilter creates a filter that adjusts sampling based on target events per second.
func NewAdaptiveSamplingFilterPresetDefaults ¶ added in v0.10.0
func NewAdaptiveSamplingFilterPresetDefaults(targetEventsPerSecond uint64, preset DampeningPreset) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilterPresetDefaults creates a filter using a preset with default rate limits
func NewAdaptiveSamplingFilterWithDampening ¶ added in v0.10.0
func NewAdaptiveSamplingFilterWithDampening(targetEventsPerSecond uint64, minRate, maxRate float64, adjustmentInterval time.Duration, hysteresisThreshold, aggressiveness, dampeningFactor float64) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilterWithDampening creates a filter with complete control including dampening factor.
func NewAdaptiveSamplingFilterWithHysteresis ¶ added in v0.10.0
func NewAdaptiveSamplingFilterWithHysteresis(targetEventsPerSecond uint64, minRate, maxRate float64, adjustmentInterval time.Duration, hysteresisThreshold, aggressiveness float64) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilterWithHysteresis creates a filter with hysteresis and aggressiveness control for stability.
func NewAdaptiveSamplingFilterWithOptions ¶ added in v0.10.0
func NewAdaptiveSamplingFilterWithOptions(targetEventsPerSecond uint64, minRate, maxRate float64, adjustmentInterval time.Duration) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilterWithOptions creates a filter with custom options.
func NewAdaptiveSamplingFilterWithPreset ¶ added in v0.10.0
func NewAdaptiveSamplingFilterWithPreset(targetEventsPerSecond uint64, preset DampeningPreset, minRate, maxRate float64) *AdaptiveSamplingFilter
NewAdaptiveSamplingFilterWithPreset creates a filter using a predefined dampening preset
func (*AdaptiveSamplingFilter) GetCurrentRate ¶ added in v0.10.0
func (f *AdaptiveSamplingFilter) GetCurrentRate() float64
GetCurrentRate returns the current sampling rate (0.0 to 1.0).
func (*AdaptiveSamplingFilter) GetStats ¶ added in v0.10.0
func (f *AdaptiveSamplingFilter) GetStats() AdaptiveSamplingStats
GetStats returns statistics about the adaptive sampling.
func (*AdaptiveSamplingFilter) IsEnabled ¶ added in v0.10.0
func (f *AdaptiveSamplingFilter) IsEnabled(event *core.LogEvent) bool
IsEnabled implements core.LogEventFilter.
func (*AdaptiveSamplingFilter) Reset ¶ added in v0.10.0
func (f *AdaptiveSamplingFilter) Reset()
Reset resets the adaptive sampling state.
type AdaptiveSamplingStats ¶ added in v0.10.0
type AdaptiveSamplingStats struct {
CurrentRate float64
TargetEventsPerSecond uint64
RecentEventCount uint64
SmoothedEventsPerSecond float64
LastAdjustment time.Time
HysteresisThreshold float64
Aggressiveness float64
}
AdaptiveSamplingStats provides statistics about adaptive sampling behavior.
type DampeningConfig ¶ added in v0.10.0
type DampeningConfig struct {
Name string
Description string
HysteresisThreshold float64 // Threshold before making adjustments
Aggressiveness float64 // How quickly to adjust rates
DampeningFactor float64 // Additional dampening for extreme variations
AdjustmentInterval time.Duration // How often to check for adjustments
}
DampeningConfig holds the configuration for a dampening preset
func GetAvailableDampeningPresets ¶ added in v0.10.0
func GetAvailableDampeningPresets() []DampeningConfig
GetAvailableDampeningPresets returns descriptions of all available presets
func GetDampeningConfig ¶ added in v0.10.0
func GetDampeningConfig(preset DampeningPreset) DampeningConfig
GetDampeningConfig returns the configuration for a given preset
type DampeningPreset ¶ added in v0.10.0
type DampeningPreset int
DampeningPreset represents a predefined dampening configuration
const ( // DampeningConservative - Heavy dampening for stable, predictable environments DampeningConservative DampeningPreset = iota // DampeningModerate - Balanced dampening for general use (default) DampeningModerate // DampeningAggressive - Light dampening for dynamic environments that need quick response DampeningAggressive // DampeningUltraStable - Maximum dampening for critical systems where stability is paramount DampeningUltraStable // DampeningResponsive - Minimal dampening for development or testing environments DampeningResponsive )
type LogBuilder ¶
type LogBuilder struct {
// contains filtered or unexported fields
}
LogBuilder provides a fluent API for building typed log entries
func (*LogBuilder) Level ¶
func (b *LogBuilder) Level(level core.LogEventLevel) *LogBuilder
Level sets the log level
func (*LogBuilder) Message ¶
func (b *LogBuilder) Message(template string) *LogBuilder
Message sets the message template
func (*LogBuilder) Property ¶
func (b *LogBuilder) Property(name string, value any) *LogBuilder
Property adds a property
func (*LogBuilder) PropertyTyped ¶
func (b *LogBuilder) PropertyTyped(name string, value any) *LogBuilder
PropertyTyped adds a typed property
type LoggerG ¶
type LoggerG[T any] interface { // Logging methods with type safety VerboseT(messageTemplate string, value T, args ...any) DebugT(messageTemplate string, value T, args ...any) InformationT(messageTemplate string, value T, args ...any) WarningT(messageTemplate string, value T, args ...any) ErrorT(messageTemplate string, value T, args ...any) FatalT(messageTemplate string, value T, args ...any) // Short method names InfoT(messageTemplate string, value T, args ...any) WarnT(messageTemplate string, value T, args ...any) // ForContextT adds a typed property ForContextT(propertyName string, value T) LoggerG[T] }
LoggerG is a generic type-safe logger interface
type LoggingLevelSwitch ¶
type LoggingLevelSwitch struct {
// contains filtered or unexported fields
}
LoggingLevelSwitch provides thread-safe, runtime control of the minimum log level. It enables dynamic adjustment of logging levels without restarting the application.
func NewLoggingLevelSwitch ¶
func NewLoggingLevelSwitch(initialLevel core.LogEventLevel) *LoggingLevelSwitch
NewLoggingLevelSwitch creates a new logging level switch with the specified initial level.
func (*LoggingLevelSwitch) Debug ¶
func (ls *LoggingLevelSwitch) Debug() *LoggingLevelSwitch
Debug sets the minimum level to Debug.
func (*LoggingLevelSwitch) Error ¶
func (ls *LoggingLevelSwitch) Error() *LoggingLevelSwitch
Error sets the minimum level to Error.
func (*LoggingLevelSwitch) Fatal ¶
func (ls *LoggingLevelSwitch) Fatal() *LoggingLevelSwitch
Fatal sets the minimum level to Fatal.
func (*LoggingLevelSwitch) Information ¶
func (ls *LoggingLevelSwitch) Information() *LoggingLevelSwitch
Information sets the minimum level to Information.
func (*LoggingLevelSwitch) IsEnabled ¶
func (ls *LoggingLevelSwitch) IsEnabled(level core.LogEventLevel) bool
IsEnabled returns true if the specified level would be processed with the current minimum level setting.
func (*LoggingLevelSwitch) Level ¶
func (ls *LoggingLevelSwitch) Level() core.LogEventLevel
Level returns the current minimum log level.
func (*LoggingLevelSwitch) SetLevel ¶
func (ls *LoggingLevelSwitch) SetLevel(level core.LogEventLevel)
SetLevel updates the minimum log level. This operation is thread-safe and takes effect immediately.
func (*LoggingLevelSwitch) Verbose ¶
func (ls *LoggingLevelSwitch) Verbose() *LoggingLevelSwitch
Verbose sets the minimum level to Verbose.
func (*LoggingLevelSwitch) Warning ¶
func (ls *LoggingLevelSwitch) Warning() *LoggingLevelSwitch
Warning sets the minimum level to Warning.
type MigrationConsent ¶ added in v0.10.0
type MigrationConsent int
MigrationConsent represents user consent for profile version migration
const ( // MigrationDeny - Do not migrate, use requested version or fail MigrationDeny MigrationConsent = iota // MigrationPrompt - Ask for consent (default, logs warning and uses current) MigrationPrompt // MigrationAuto - Automatically migrate to latest version MigrationAuto )
type MigrationPolicy ¶ added in v0.10.0
type MigrationPolicy struct {
Consent MigrationConsent // How to handle missing versions
PreferStable bool // Prefer stable versions over latest
MaxVersionDistance int // Maximum version distance for auto-migration (0 = no limit)
}
MigrationPolicy controls how profile version migration is handled
func GetMigrationPolicy ¶ added in v0.10.0
func GetMigrationPolicy() MigrationPolicy
GetMigrationPolicy returns the current migration policy
type Option ¶
type Option func(*config)
Option is a functional option for configuring a logger.
func WithAutoSourceContext ¶ added in v0.2.0
func WithAutoSourceContext() Option
WithAutoSourceContext adds automatic source context detection.
func WithCallers ¶
WithCallers adds caller information enrichment.
func WithCallersInfo ¶
func WithCallersInfo() Option
WithCallersInfo adds caller information enrichment with default skip.
func WithCapturer ¶ added in v0.6.0
WithCapturer sets the capturer for the pipeline.
func WithCapturing ¶ added in v0.6.0
func WithCapturing() Option
WithCapturing adds the cached capturer for better performance.
func WithCapturingDepth ¶ added in v0.6.0
WithCapturingDepth adds capturing with a specific max depth.
func WithCommonEnvironment ¶
func WithCommonEnvironment() Option
WithCommonEnvironment adds enrichers for common environment variables.
func WithConditional ¶ added in v0.10.0
WithConditional adds a conditional sink that only forwards events matching the predicate.
func WithConsoleProperties ¶
func WithConsoleProperties() Option
WithConsoleProperties adds a console sink that displays properties.
func WithConsoleTemplate ¶ added in v0.2.0
WithConsoleTemplate adds a console sink with a custom output template.
func WithConsoleTemplateAndTheme ¶ added in v0.9.0
func WithConsoleTemplateAndTheme(template string, theme *sinks.ConsoleTheme) Option
WithConsoleTemplateAndTheme adds a console sink with both a custom output template and theme.
func WithConsoleTheme ¶ added in v0.2.0
func WithConsoleTheme(theme *sinks.ConsoleTheme) Option
WithConsoleTheme adds a console sink with a custom theme.
func WithContextDeadlineWarning ¶ added in v0.10.0
func WithContextDeadlineWarning(threshold time.Duration, opts ...enrichers.DeadlineOption) Option
WithContextDeadlineWarning enables automatic context deadline detection and warning. When a context deadline is approaching (within the specified threshold), the logger will automatically add deadline information to log events and optionally upgrade their level to Warning.
Example:
logger := mtlog.New(
mtlog.WithConsole(),
mtlog.WithContextDeadlineWarning(100*time.Millisecond),
)
This will warn when operations are within 100ms of their deadline.
func WithCorrelationId ¶
WithCorrelationId adds a fixed correlation ID to all log events.
func WithCustomCapturing ¶ added in v0.6.0
WithCustomCapturing adds a capturer with custom limits.
func WithDeadlineOptions ¶ added in v0.10.0
func WithDeadlineOptions(opts ...enrichers.DeadlineOption) Option
WithDeadlineOptions applies additional deadline enricher options to an existing configuration. This is useful for fine-tuning deadline behavior without recreating the entire enricher.
func WithDeadlinePercentageOnly ¶ added in v0.10.0
func WithDeadlinePercentageOnly(percent float64, opts ...enrichers.DeadlineOption) Option
WithDeadlinePercentageOnly configures deadline warnings based only on percentage of time remaining, without requiring an absolute threshold. For example, 0.2 means warn when 20% of time remains.
Example:
logger := mtlog.New(
mtlog.WithDeadlinePercentageOnly(0.2), // Warn at 20% remaining
)
func WithDeadlinePercentageThreshold ¶ added in v0.10.0
func WithDeadlinePercentageThreshold(threshold time.Duration, percent float64, opts ...enrichers.DeadlineOption) Option
WithDeadlinePercentageThreshold configures deadline warnings based on percentage of time remaining. For example, 0.1 means warn when 10% of the total time remains.
This can be used together with absolute threshold - warnings will trigger when either condition is met.
func WithDefaultSampling ¶ added in v0.10.0
WithDefaultSampling sets a default sampling rate for all messages. This can be overridden by per-message sampling methods.
func WithDurableBuffer ¶
func WithDurableBuffer(wrapped core.LogEventSink, bufferPath string) Option
WithDurableBuffer adds durable buffering to a sink for reliability.
func WithDurableBufferAdvanced ¶
func WithDurableBufferAdvanced(wrapped core.LogEventSink, options sinks.DurableOptions) Option
WithDurableBufferAdvanced adds durable buffering with advanced options.
func WithDurableElasticsearch ¶
WithDurableElasticsearch adds an Elasticsearch sink with durable buffering.
func WithDurableSeq ¶
WithDurableSeq adds a Seq sink with durable buffering.
func WithDurableSplunk ¶
WithDurableSplunk adds a Splunk sink with durable buffering.
func WithDynamicLevel ¶
func WithDynamicLevel(levelSwitch *LoggingLevelSwitch) Option
WithDynamicLevel enables dynamic level control using a level switch. This is an alias for WithLevelSwitch for better readability.
func WithElasticsearch ¶
WithElasticsearch adds an Elasticsearch sink with default configuration.
func WithElasticsearchAPIKey ¶
WithElasticsearchAPIKey adds an Elasticsearch sink with API key authentication.
func WithElasticsearchAdvanced ¶
func WithElasticsearchAdvanced(url string, opts ...sinks.ElasticsearchOption) Option
WithElasticsearchAdvanced adds an Elasticsearch sink with advanced options.
func WithElasticsearchBasicAuth ¶
WithElasticsearchBasicAuth adds an Elasticsearch sink with basic authentication.
func WithEnricher ¶
func WithEnricher(enricher core.LogEventEnricher) Option
WithEnricher adds an enricher to the pipeline.
func WithEnvironment ¶
WithEnvironment adds environment variable enrichment.
func WithEnvironmentVariables ¶
WithEnvironmentVariables adds enrichers for multiple environment variables.
func WithExcludeFilter ¶
WithExcludeFilter adds a filter that excludes events matching the predicate.
func WithFileTemplate ¶ added in v0.2.0
WithFileTemplate adds a file sink with a custom output template.
func WithFilter ¶
func WithFilter(filter core.LogEventFilter) Option
WithFilter adds a filter to the pipeline.
func WithHashSampling ¶
WithHashSampling adds a hash-based sampling filter.
func WithLevelFilter ¶
func WithLevelFilter(minimumLevel core.LogEventLevel) Option
WithLevelFilter adds a minimum level filter.
func WithLevelSwitch ¶
func WithLevelSwitch(levelSwitch *LoggingLevelSwitch) Option
WithLevelSwitch enables dynamic level control using the specified level switch. When a level switch is provided, it takes precedence over the static minimum level.
func WithMinimumLevel ¶
func WithMinimumLevel(level core.LogEventLevel) Option
WithMinimumLevel sets the minimum log level.
func WithMinimumLevelOverrides ¶ added in v0.2.0
func WithMinimumLevelOverrides(defaultLevel core.LogEventLevel, overrides map[string]core.LogEventLevel) Option
WithMinimumLevelOverrides adds source context-based level filtering.
func WithProperties ¶
WithProperties adds multiple global properties.
func WithProperty ¶
WithProperty adds a global property to all log events.
func WithPropertyFilter ¶
WithPropertyFilter adds a filter that matches a specific property value.
func WithRateLimit ¶
WithRateLimit adds a rate limiting filter.
func WithRouter ¶ added in v0.10.0
WithRouter adds a router sink for sophisticated event routing.
func WithRouterDefault ¶ added in v0.10.0
func WithRouterDefault(mode sinks.RoutingMode, defaultSink core.LogEventSink, routes ...sinks.Route) Option
WithRouterDefault adds a router sink with a default fallback sink.
func WithRouterMode ¶ added in v0.10.0
func WithRouterMode(mode sinks.RoutingMode, routes ...sinks.Route) Option
WithRouterMode adds a router sink with a specific routing mode.
func WithSamplingMemoryLimit ¶ added in v0.10.0
WithSamplingMemoryLimit sets a maximum number of sampling keys to track. This helps prevent unbounded memory growth from dynamic sampling keys. The limit applies to both group sampling and backoff sampling caches.
func WithSamplingPolicy ¶ added in v0.10.0
func WithSamplingPolicy(policy core.SamplingPolicy) Option
WithSamplingPolicy creates an Option from a custom SamplingPolicy.
func WithSeqAPIKey ¶
WithSeqAPIKey adds a Seq sink with API key authentication.
func WithSeqAdvanced ¶
WithSeqAdvanced adds a Seq sink with advanced options.
func WithSourceContext ¶ added in v0.2.0
WithSourceContext adds source context enrichment with the specified context.
func WithSplunk ¶
WithSplunk adds a Splunk sink to the logger.
func WithSplunkAdvanced ¶
func WithSplunkAdvanced(url, token string, opts ...sinks.SplunkOption) Option
WithSplunkAdvanced adds a Splunk sink with advanced options.
type Repository ¶ added in v0.3.0
Repository interface for testing - used across multiple test files
type SamplingConfigBuilder ¶ added in v0.10.0
type SamplingConfigBuilder struct {
// contains filtered or unexported fields
}
SamplingConfigBuilder provides a fluent interface for building complex sampling configurations.
func Sampling ¶ added in v0.10.0
func Sampling() *SamplingConfigBuilder
Sampling creates a new sampling configuration builder.
func (*SamplingConfigBuilder) AsOption ¶ added in v0.10.0
func (s *SamplingConfigBuilder) AsOption() Option
AsOption is an alias for Build for convenience.
func (*SamplingConfigBuilder) Backoff ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Backoff(key string, factor float64) *SamplingConfigBuilder
Backoff samples with exponential backoff.
func (*SamplingConfigBuilder) Build ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Build() Option
Build returns an Option that applies all the configured sampling filters in a pipeline.
Pipeline Mode (Build): Each filter processes the output of the previous filter sequentially.
Event → Every(2) → Rate(0.5) → First(10) → Output
↓ 50% ↓ 25% ↓ 10 max
In this example: - Every(2): Passes 50% of events (every 2nd message) - Rate(0.5): Processes only the events that passed Every(2), passes 50% of those (25% total) - First(10): Processes only events that passed both previous filters, passes first 10
func (*SamplingConfigBuilder) CombineAND ¶ added in v0.10.0
func (s *SamplingConfigBuilder) CombineAND() Option
CombineAND creates a composite filter that requires all conditions to pass.
Composite AND Mode: All filters evaluate the same event independently. ALL must approve for the event to pass.
Event → [Every(2)] ⎤
→ [Rate(0.5)] ⎬ → AND → Output (only if ALL approve)
→ [First(10)] ⎦
In this example, an event passes only if: - Every(2) approves (even-numbered events), AND - Rate(0.5) approves (50% random chance), AND - First(10) approves (within first 10 evaluations)
func (*SamplingConfigBuilder) CombineOR ¶ added in v0.10.0
func (s *SamplingConfigBuilder) CombineOR() Option
CombineOR creates a composite filter that passes if any condition passes.
Composite OR Mode: All filters evaluate the same event independently. ANY can approve for the event to pass.
Event → [Every(2)] ⎤
→ [Rate(0.5)] ⎬ → OR → Output (if ANY approve)
→ [First(10)] ⎦
In this example, an event passes if: - Every(2) approves (even-numbered events), OR - Rate(0.5) approves (50% random chance), OR - First(10) approves (within first 10 evaluations)
func (*SamplingConfigBuilder) Duration ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Duration(d time.Duration) *SamplingConfigBuilder
Duration samples at most once per duration.
func (*SamplingConfigBuilder) Every ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Every(n uint64) *SamplingConfigBuilder
Every samples every Nth message.
func (*SamplingConfigBuilder) First ¶ added in v0.10.0
func (s *SamplingConfigBuilder) First(n uint64) *SamplingConfigBuilder
First logs only the first N occurrences.
func (*SamplingConfigBuilder) Group ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Group(name string, n uint64) *SamplingConfigBuilder
Group samples within a named group.
func (*SamplingConfigBuilder) Rate ¶ added in v0.10.0
func (s *SamplingConfigBuilder) Rate(rate float32) *SamplingConfigBuilder
Rate samples a percentage of messages (0.0 to 1.0).
func (*SamplingConfigBuilder) When ¶ added in v0.10.0
func (s *SamplingConfigBuilder) When(predicate func() bool, n uint64) *SamplingConfigBuilder
When samples conditionally based on a predicate.
type SamplingProfile ¶ added in v0.10.0
type SamplingProfile struct {
// contains filtered or unexported fields
}
SamplingProfile represents a predefined sampling configuration for common scenarios with versioning support
func GetProfileWithMigration ¶ added in v0.10.0
func GetProfileWithMigration(profileName, requestedVersion string) (SamplingProfile, string, bool)
GetProfileWithMigration retrieves a profile with automatic migration support Returns the profile, the actual version used, and whether it was found
func GetProfileWithVersion ¶ added in v0.10.0
func GetProfileWithVersion(profileName, version string) (SamplingProfile, bool)
GetProfileWithVersion returns a specific version of a profile
type SeqLevelController ¶
type SeqLevelController struct {
// contains filtered or unexported fields
}
SeqLevelController automatically updates a LoggingLevelSwitch based on the minimum level configured in Seq. This enables centralized level control where Seq acts as the source of truth for log levels.
func NewSeqLevelController ¶
func NewSeqLevelController(levelSwitch *LoggingLevelSwitch, seqSink *sinks.SeqSink, options SeqLevelControllerOptions) *SeqLevelController
NewSeqLevelController creates a new controller that synchronizes a level switch with Seq's minimum level setting. The controller will periodically query Seq and update the level switch when changes are detected.
func (*SeqLevelController) Close ¶
func (slc *SeqLevelController) Close()
Close stops the level controller and waits for background operations to complete.
func (*SeqLevelController) ForceCheck ¶
func (slc *SeqLevelController) ForceCheck() error
ForceCheck immediately queries Seq for the current level and updates the level switch if necessary. This is useful for testing or immediate synchronization.
func (*SeqLevelController) GetCurrentLevel ¶
func (slc *SeqLevelController) GetCurrentLevel() core.LogEventLevel
GetCurrentLevel returns the current level from the level switch.
func (*SeqLevelController) GetLastSeqLevel ¶
func (slc *SeqLevelController) GetLastSeqLevel() core.LogEventLevel
GetLastSeqLevel returns the last level retrieved from Seq.
type SeqLevelControllerBuilder ¶
type SeqLevelControllerBuilder struct {
// contains filtered or unexported fields
}
SeqLevelControllerBuilder provides a fluent interface for building Seq level controllers.
func NewSeqLevelControllerBuilder ¶
func NewSeqLevelControllerBuilder(serverURL string) *SeqLevelControllerBuilder
NewSeqLevelControllerBuilder creates a new builder for Seq level controllers.
func (*SeqLevelControllerBuilder) Build ¶
func (b *SeqLevelControllerBuilder) Build() (Option, *LoggingLevelSwitch, *SeqLevelController)
Build creates the Seq level controller and returns the logger option, level switch, and controller.
func (*SeqLevelControllerBuilder) WithCheckInterval ¶
func (b *SeqLevelControllerBuilder) WithCheckInterval(interval time.Duration) *SeqLevelControllerBuilder
WithCheckInterval sets the interval for querying Seq.
func (*SeqLevelControllerBuilder) WithErrorHandler ¶
func (b *SeqLevelControllerBuilder) WithErrorHandler(onError func(error)) *SeqLevelControllerBuilder
WithErrorHandler sets the error handler for level checking failures.
func (*SeqLevelControllerBuilder) WithInitialCheck ¶
func (b *SeqLevelControllerBuilder) WithInitialCheck(initialCheck bool) *SeqLevelControllerBuilder
WithInitialCheck controls whether to perform an initial level check.
func (*SeqLevelControllerBuilder) WithLevelSwitch ¶
func (b *SeqLevelControllerBuilder) WithLevelSwitch(levelSwitch *LoggingLevelSwitch) *SeqLevelControllerBuilder
WithLevelSwitch uses an existing level switch instead of creating a new one.
func (*SeqLevelControllerBuilder) WithSeqAPIKey ¶
func (b *SeqLevelControllerBuilder) WithSeqAPIKey(apiKey string) *SeqLevelControllerBuilder
WithSeqAPIKey adds API key authentication for Seq.
type SeqLevelControllerOptions ¶
type SeqLevelControllerOptions struct {
// CheckInterval is how often to query Seq for level changes.
// Default: 30 seconds
CheckInterval time.Duration
// OnError is called when an error occurs during level checking.
// Default: no-op
OnError func(error)
// InitialCheck determines whether to perform an initial check immediately.
// Default: true
InitialCheck bool
}
SeqLevelControllerOptions configures a Seq level controller.
type StructuredLogger ¶
type StructuredLogger struct {
// contains filtered or unexported fields
}
StructuredLogger provides type-safe structured logging
func NewStructured ¶
func NewStructured(opts ...Option) *StructuredLogger
NewStructured creates a new structured logger
func (*StructuredLogger) Log ¶
func (sl *StructuredLogger) Log(level core.LogEventLevel, messageTemplate string, properties *core.PropertyBag)
Log logs with a typed property bag
func (*StructuredLogger) LogWith ¶
func (sl *StructuredLogger) LogWith() *LogBuilder
LogWith logs with typed properties using a builder pattern
type TypeNameCacheStats ¶ added in v0.3.0
type TypeNameCacheStats struct {
Hits int64 // Number of cache hits
Misses int64 // Number of cache misses
Evictions int64 // Number of cache evictions due to LRU policy
HitRatio float64 // Hit ratio as a percentage (0-100)
Size int64 // Number of entries currently in the cache
MaxSize int64 // Maximum cache size before eviction
}
TypeNameCacheStats provides performance statistics for the type name cache.
func GetTypeNameCacheStats ¶ added in v0.3.0
func GetTypeNameCacheStats() TypeNameCacheStats
GetTypeNameCacheStats returns current cache performance statistics.
type TypeNameOptions ¶ added in v0.3.0
type TypeNameOptions struct {
// IncludePackage determines whether to include the package path in the type name.
// Default: false (only type name)
IncludePackage bool
// PackageDepth limits how many package path segments to include when IncludePackage is true.
// 0 means include full package path. Default: 1 (only immediate package)
PackageDepth int
// Prefix is prepended to the type name for consistent naming.
// Example: "MyApp." would result in "MyApp.User" for User type
Prefix string
// Suffix is appended to the type name.
// Example: ".Service" would result in "User.Service" for User type
Suffix string
// SimplifyAnonymous controls how anonymous struct types are displayed.
// When true, anonymous structs return "AnonymousStruct" instead of their full definition.
// Default: false (shows full struct definition)
SimplifyAnonymous bool
// WarnOnUnknown controls whether to log warnings for "Unknown" type names.
// When true, warnings are logged to help with debugging interface types and unresolvable types.
// When false, warnings are suppressed to reduce log noise in production.
// Default: true (warnings enabled)
WarnOnUnknown bool
}
TypeNameOptions controls how type names are extracted and formatted for SourceContext.
Use with extractTypeName to create custom loggers with more control over type name formatting than the default ForType function. See examples/fortype/main.go demonstrateTypeNameOptions for practical usage examples.
Example:
opts := TypeNameOptions{IncludePackage: true, Prefix: "MyApp."}
name := extractTypeName[User](opts) // Result: "MyApp.mypackage.User"
logger := baseLogger.ForContext("SourceContext", name)
type TypedLogger ¶
type TypedLogger[T any] struct { // contains filtered or unexported fields }
TypedLogger wraps a regular logger with type-safe methods
func (*TypedLogger[T]) DebugT ¶
func (l *TypedLogger[T]) DebugT(messageTemplate string, value T, args ...any)
DebugT logs at debug level with typed value
func (*TypedLogger[T]) ErrorT ¶
func (l *TypedLogger[T]) ErrorT(messageTemplate string, value T, args ...any)
ErrorT logs at error level with typed value
func (*TypedLogger[T]) FatalT ¶
func (l *TypedLogger[T]) FatalT(messageTemplate string, value T, args ...any)
FatalT logs at fatal level with typed value
func (*TypedLogger[T]) ForContextT ¶
func (l *TypedLogger[T]) ForContextT(propertyName string, value T) LoggerG[T]
ForContextT adds a typed property to the logger context
func (*TypedLogger[T]) InfoT ¶
func (l *TypedLogger[T]) InfoT(messageTemplate string, value T, args ...any)
InfoT writes an information-level log event with a typed value (alias for InformationT)
func (*TypedLogger[T]) InformationT ¶
func (l *TypedLogger[T]) InformationT(messageTemplate string, value T, args ...any)
InformationT logs at information level with typed value
func (*TypedLogger[T]) VerboseT ¶
func (l *TypedLogger[T]) VerboseT(messageTemplate string, value T, args ...any)
VerboseT logs at verbose level with typed value
func (*TypedLogger[T]) WarnT ¶
func (l *TypedLogger[T]) WarnT(messageTemplate string, value T, args ...any)
WarnT writes a warning-level log event with a typed value (alias for WarningT)
func (*TypedLogger[T]) WarningT ¶
func (l *TypedLogger[T]) WarningT(messageTemplate string, value T, args ...any)
WarningT logs at warning level with typed value
type UserRepository ¶ added in v0.3.0
type UserRepository struct{}
UserRepository implements Repository for testing
func (*UserRepository) Save ¶ added in v0.3.0
func (ur *UserRepository) Save(any) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
otel
module
|
|
|
sentry
module
|
|
|
cmd
|
|
|
mtlog-analyzer
module
|
|
|
Package core provides the fundamental interfaces and types for mtlog.
|
Package core provides the fundamental interfaces and types for mtlog. |
|
examples
|
|
|
async
command
|
|
|
basic
command
|
|
|
capturing
command
|
|
|
conditional
command
|
|
|
configuration
command
|
|
|
context
command
|
|
|
custom-sink
command
|
|
|
deadline-awareness
command
Package main demonstrates mtlog's context deadline awareness feature.
|
Package main demonstrates mtlog's context deadline awareness feature. |
|
deadline-awareness-metrics
command
Package main demonstrates integrating mtlog deadline awareness with metrics systems.
|
Package main demonstrates integrating mtlog deadline awareness with metrics systems. |
|
durable
command
|
|
|
dynamic-levels
command
|
|
|
elasticsearch
command
|
|
|
enrichers
command
|
|
|
filtering
command
|
|
|
fortype
command
Package main demonstrates using ForType for automatic SourceContext from type names.
|
Package main demonstrates using ForType for automatic SourceContext from type names. |
|
generics
command
|
|
|
go-templates
command
|
|
|
logcontext
command
Package main demonstrates using LogContext for scoped properties.
|
Package main demonstrates using LogContext for scoped properties. |
|
logvalue
command
|
|
|
otel
command
Package main demonstrates using OTEL-style dotted property names with mtlog.
|
Package main demonstrates using OTEL-style dotted property names with mtlog. |
|
output-templates
command
|
|
|
rolling
command
|
|
|
router
command
|
|
|
sampling
command
|
|
|
sampling-advanced
command
|
|
|
sampling-debug
command
|
|
|
sampling-monitoring
command
|
|
|
sampling-profiles
command
|
|
|
seq
command
|
|
|
showcase
command
|
|
|
splunk
command
|
|
|
themes
command
|
|
|
with
command
|
|
|
goland-plugin
|
|
|
src/test/resources/testData
command
|
|
|
internal
|
|
|
Package selflog provides internal diagnostic logging for mtlog.
|
Package selflog provides internal diagnostic logging for mtlog. |
