Documentation
¶
Index ¶
- Variables
- func AddPIIField(field string)
- func AddSensitiveField(field string)
- func ClearFieldCache()
- func DebugMsg(message string)
- func DebugStructured(message string, fields ...ZField)
- func ErrorMsg(message string)
- func ErrorStructured(message string, fields ...ZField)
- func GetUltraFastTimestamp() string
- func InfoMsg(message string)
- func InfoStructured(message string, fields ...ZField)
- func InfoWithFields(message string, fields map[string]any)
- func JSON(severity, message string, optionalParams ...string)
- func Log(level, message string, optionalParams ...string)
- func MaskPIIData()
- func MaskSensitiveData()
- func Plain(severity, message string, optionalParams ...string)
- func SetAllMasking(enabled bool)
- func SetComponent(component string)
- func SetDevelopmentMode()
- func SetFormat(format string)
- func SetJSONFormat()
- func SetLevel(level string)
- func SetMaskString(mask string)
- func SetOutput(writer io.Writer)
- func SetOutputToDiscard()
- func SetPIIFields(fields []string)
- func SetPIIMaskString(mask string)
- func SetPIIMode(mode string)
- func SetPlainFormat()
- func SetProductionMode()
- func SetSensitiveFields(fields []string)
- func SetSensitiveMode(mode string)
- func SetShowCaller(show bool)
- func SetTimestampPrecision(precision TimestampPrecision)
- func SetTimestampPrecisionConfig(precision TimestampPrecision)
- func SetUltraFastTimestampPrecision(intervalSeconds int64)
- func SetVersion(version string)
- func ShowPIIData()
- func ShowSensitiveData()
- func WarnMsg(message string)
- func WarnStructured(message string, fields ...ZField)
- func WithPooledFields(fn func(*PooledFields))
- type BoolZField
- type DebugLogger
- type DurationZField
- type ErrorLogger
- type Fields
- func (f Fields) Add(key string, value any) Fields
- func (f Fields) Any(key string, value any) Fields
- func (f Fields) Bool(key string, value bool) Fields
- func (f Fields) Clone() Fields
- func (f Fields) Error(key string, err error) Fields
- func (f Fields) Float64(key string, value float64) Fields
- func (f Fields) Int(key string, value int) Fields
- func (f Fields) Int64(key string, value int64) Fields
- func (f Fields) Merge(other Fields) Fields
- func (f Fields) Set(key string, value any) Fields
- func (f Fields) String(key, value string) Fields
- func (f Fields) Time(key string, value time.Time) Fields
- func (f Fields) ToMap() map[string]any
- func (f Fields) With(key string, value any) Fields
- type Float64ZField
- type InfoLogger
- type Int64ZField
- type IntZField
- type LogEntry
- type LogLevel
- type Logger
- type OutputFormat
- type PIIDataMode
- type PooledFields
- func (pf *PooledFields) Bool(key string, value bool) *PooledFields
- func (pf *PooledFields) Error(key string, err error) *PooledFields
- func (pf *PooledFields) Float64(key string, value float64) *PooledFields
- func (pf *PooledFields) Int(key string, value int) *PooledFields
- func (pf *PooledFields) Int64(key string, value int64) *PooledFields
- func (pf *PooledFields) Release()
- func (pf *PooledFields) String(key, value string) *PooledFields
- func (pf *PooledFields) Time(key string, value time.Time) *PooledFields
- func (pf *PooledFields) ToMap() map[string]any
- type SensitiveDataMode
- type StringZField
- type TimeZField
- type TimestampPrecision
- type WarnLogger
- type ZField
- type ZeroAllocEncoder
Constants ¶
This section is empty.
Variables ¶
var ( // Info provides emit.Info.FieldWithMessage() and other methods Info = InfoLogger{} // Error provides emit.Error.FieldWithMessage() and other methods Error = ErrorLogger{} // Warn provides emit.Warn.FieldWithMessage() and other methods Warn = WarnLogger{} // Debug provides emit.Debug.FieldWithMessage() and other methods Debug = DebugLogger{} )
Functions ¶
func AddPIIField ¶
func AddPIIField(field string)
AddPIIField adds a custom field pattern to be masked as PII
func AddSensitiveField ¶
func AddSensitiveField(field string)
AddSensitiveField adds a custom field pattern to be masked
func ClearFieldCache ¶
func ClearFieldCache()
ClearFieldCache clears the field pattern cache (for testing or dynamic field updates)
func DebugStructured ¶ added in v1.2.0
DebugStructured logs at DEBUG level with structured fields optimization
func ErrorStructured ¶ added in v1.2.0
ErrorStructured logs at ERROR level with structured fields optimization
func GetUltraFastTimestamp ¶ added in v1.2.0
func GetUltraFastTimestamp() string
GetUltraFastTimestamp returns a cached timestamp string Optimized for sub-20ns performance in the common case
func InfoMsg ¶ added in v1.2.0
func InfoMsg(message string)
Simple message logging functions with clear names
func InfoStructured ¶ added in v1.2.0
InfoStructured logs at INFO level with structured fields optimization
func InfoWithFields ¶
InfoWithFields logs an info message with a map of fields
func MaskPIIData ¶
func MaskPIIData()
MaskPIIData enables masking of PII fields (default and recommended)
func MaskSensitiveData ¶
func MaskSensitiveData()
MaskSensitiveData enables masking of sensitive fields (default and recommended)
func SetAllMasking ¶
func SetAllMasking(enabled bool)
SetAllMasking enables or disables both sensitive and PII masking
func SetComponent ¶
func SetComponent(component string)
SetComponent sets the component name for the default logger
func SetDevelopmentMode ¶
func SetDevelopmentMode()
SetDevelopmentMode disables all masking for development
func SetMaskString ¶
func SetMaskString(mask string)
SetMaskString sets the string used to mask sensitive data
func SetOutputToDiscard ¶ added in v1.2.0
func SetOutputToDiscard()
SetOutputToDiscard redirects output to discard for benchmarking
func SetPIIFields ¶
func SetPIIFields(fields []string)
SetPIIFields replaces the default PII field patterns
func SetPIIMaskString ¶
func SetPIIMaskString(mask string)
SetPIIMaskString sets the string used to mask PII data
func SetPlainFormat ¶
func SetPlainFormat()
SetPlainFormat switches to plain text output for development
func SetProductionMode ¶
func SetProductionMode()
SetProductionMode enables all masking for production
func SetSensitiveFields ¶
func SetSensitiveFields(fields []string)
SetSensitiveFields replaces the default sensitive field patterns
func SetSensitiveMode ¶
func SetSensitiveMode(mode string)
SetSensitiveMode sets whether to mask sensitive data
func SetShowCaller ¶
func SetShowCaller(show bool)
SetShowCaller enables or disables caller information
func SetTimestampPrecision ¶ added in v1.2.0
func SetTimestampPrecision(precision TimestampPrecision)
SetTimestampPrecision sets the global timestamp precision
func SetTimestampPrecisionConfig ¶ added in v1.2.0
func SetTimestampPrecisionConfig(precision TimestampPrecision)
SetTimestampPrecisionConfig sets the timestamp precision for the logging system
func SetUltraFastTimestampPrecision ¶ added in v1.2.0
func SetUltraFastTimestampPrecision(intervalSeconds int64)
SetUltraFastTimestampPrecision sets the update interval for the ultra-fast cache Lower intervals provide more accurate timestamps but slight performance cost
func SetVersion ¶
func SetVersion(version string)
SetVersion sets the version for the default logger
func ShowPIIData ¶
func ShowPIIData()
ShowPIIData disables masking of PII fields (not recommended for production)
func ShowSensitiveData ¶
func ShowSensitiveData()
ShowSensitiveData disables masking of sensitive fields (not recommended for production)
func WarnStructured ¶ added in v1.2.0
WarnStructured logs at WARN level with structured fields optimization
func WithPooledFields ¶
func WithPooledFields(fn func(*PooledFields))
WithPooledFields executes a function with pooled fields and automatically releases them
Types ¶
type BoolZField ¶
BoolZField represents a boolean field with zero allocations
func ZBool ¶
func ZBool(key string, value bool) BoolZField
ZBool creates a zero-allocation bool field
func (BoolZField) IsPII ¶
func (f BoolZField) IsPII() bool
func (BoolZField) IsSensitive ¶
func (f BoolZField) IsSensitive() bool
func (BoolZField) WriteToEncoder ¶
func (f BoolZField) WriteToEncoder(enc *ZeroAllocEncoder)
type DebugLogger ¶ added in v1.2.0
type DebugLogger struct{}
DebugLogger provides debug-level logging methods with clear, simple names
func (DebugLogger) Field ¶ added in v1.2.0
func (DebugLogger) Field(msg string, fields Fields)
Field logs a debug message with structured fields
func (DebugLogger) KeyValue ¶ added in v1.2.0
func (DebugLogger) KeyValue(msg string, keysAndValues ...interface{})
KeyValue logs a debug message with key-value pairs
func (DebugLogger) Msg ¶ added in v1.2.0
func (DebugLogger) Msg(message string)
Msg logs a simple debug message
func (DebugLogger) Pool ¶ added in v1.2.0
func (DebugLogger) Pool(msg string, fn func(*PooledFields))
Pool logs a debug message using memory-pooled fields
func (DebugLogger) StructuredFields ¶ added in v1.2.0
func (DebugLogger) StructuredFields(msg string, fields ...ZField)
StructuredFields logs a debug message with ultra-fast structured fields (Phase 5C)
type DurationZField ¶
DurationZField represents a duration field with zero allocations
func ZDuration ¶
func ZDuration(key string, value time.Duration) DurationZField
ZDuration creates a zero-allocation duration field
func (DurationZField) IsPII ¶
func (f DurationZField) IsPII() bool
func (DurationZField) IsSensitive ¶
func (f DurationZField) IsSensitive() bool
func (DurationZField) WriteToEncoder ¶
func (f DurationZField) WriteToEncoder(enc *ZeroAllocEncoder)
type ErrorLogger ¶ added in v1.2.0
type ErrorLogger struct{}
ErrorLogger provides error-level logging methods with clear, simple names
func (ErrorLogger) Field ¶ added in v1.2.0
func (ErrorLogger) Field(msg string, fields Fields)
Field logs an error message with structured fields
func (ErrorLogger) KeyValue ¶ added in v1.2.0
func (ErrorLogger) KeyValue(msg string, keysAndValues ...interface{})
KeyValue logs an error message with key-value pairs
func (ErrorLogger) Msg ¶ added in v1.2.0
func (ErrorLogger) Msg(message string)
Msg logs a simple error message
func (ErrorLogger) Pool ¶ added in v1.2.0
func (ErrorLogger) Pool(msg string, fn func(*PooledFields))
Pool logs an error message using memory-pooled fields
func (ErrorLogger) StructuredFields ¶ added in v1.2.0
func (ErrorLogger) StructuredFields(msg string, fields ...ZField)
StructuredFields logs an error message with ultra-fast structured fields (Phase 5C)
type Fields ¶
Fields provides a fluent API for building log fields
func ErrorField ¶
ErrorField creates a Fields object with an error field
func StringField ¶
StringField creates a Fields object with a string field
type Float64ZField ¶
Float64ZField represents a float64 field with zero allocations
func ZFloat64 ¶
func ZFloat64(key string, value float64) Float64ZField
ZFloat64 creates a zero-allocation float64 field
func (Float64ZField) IsPII ¶
func (f Float64ZField) IsPII() bool
func (Float64ZField) IsSensitive ¶
func (f Float64ZField) IsSensitive() bool
func (Float64ZField) WriteToEncoder ¶
func (f Float64ZField) WriteToEncoder(enc *ZeroAllocEncoder)
type InfoLogger ¶ added in v1.2.0
type InfoLogger struct{}
InfoLogger provides info-level logging methods with clear, simple names
func (InfoLogger) Field ¶ added in v1.2.0
func (InfoLogger) Field(msg string, fields Fields)
Field logs an info message with structured fields
func (InfoLogger) KeyValue ¶ added in v1.2.0
func (InfoLogger) KeyValue(msg string, keysAndValues ...interface{})
KeyValue logs an info message with key-value pairs
func (InfoLogger) Msg ¶ added in v1.2.0
func (InfoLogger) Msg(message string)
Msg logs a simple info message
func (InfoLogger) Pool ¶ added in v1.2.0
func (InfoLogger) Pool(msg string, fn func(*PooledFields))
Pool logs an info message using memory-pooled fields
func (InfoLogger) StructuredFields ¶ added in v1.2.0
func (InfoLogger) StructuredFields(msg string, fields ...ZField)
StructuredFields logs an info message with structured fields
type Int64ZField ¶
Int64ZField represents an int64 field with zero allocations
func ZInt64 ¶
func ZInt64(key string, value int64) Int64ZField
ZInt64 creates a zero-allocation int64 field
func (Int64ZField) IsPII ¶
func (f Int64ZField) IsPII() bool
func (Int64ZField) IsSensitive ¶
func (f Int64ZField) IsSensitive() bool
func (Int64ZField) WriteToEncoder ¶
func (f Int64ZField) WriteToEncoder(enc *ZeroAllocEncoder)
type IntZField ¶
IntZField represents an integer field with zero allocations
func (IntZField) IsSensitive ¶
func (IntZField) WriteToEncoder ¶
func (f IntZField) WriteToEncoder(enc *ZeroAllocEncoder)
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Component string `json:"component,omitempty"`
Version string `json:"version,omitempty"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Function string `json:"function,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
}
LogEntry represents a structured log entry for Kubernetes
type LogLevel ¶
type LogLevel int
LogLevel represents the logging level
func ParseLogLevel ¶
ParseLogLevel parses a string into a LogLevel
func (LogLevel) StringFast ¶ added in v1.2.0
StringFast returns the string representation of the log level with optimized performance
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents the JSON logger
func (*Logger) DebugStructured ¶ added in v1.2.0
func (*Logger) ErrorStructured ¶ added in v1.2.0
func (*Logger) InfoStructured ¶ added in v1.2.0
func (*Logger) WarnStructured ¶ added in v1.2.0
type OutputFormat ¶
type OutputFormat int
OutputFormat represents the output format type
const ( JSON_FORMAT OutputFormat = iota PLAIN_FORMAT )
type PIIDataMode ¶
type PIIDataMode int
PIIDataMode represents how to handle PII data
const ( MASK_PII PIIDataMode = iota // Default: mask PII data SHOW_PII // Show PII data (not recommended for production) )
type PooledFields ¶
type PooledFields struct {
// contains filtered or unexported fields
}
Optimized Fields implementation with pooling
func NewPooledFields ¶
func NewPooledFields() *PooledFields
NewPooledFields creates a new PooledFields using memory pool
func (*PooledFields) Bool ¶
func (pf *PooledFields) Bool(key string, value bool) *PooledFields
Bool adds a boolean field
func (*PooledFields) Error ¶
func (pf *PooledFields) Error(key string, err error) *PooledFields
Error adds an error field
func (*PooledFields) Float64 ¶
func (pf *PooledFields) Float64(key string, value float64) *PooledFields
Float64 adds a float64 field
func (*PooledFields) Int ¶
func (pf *PooledFields) Int(key string, value int) *PooledFields
Int adds an integer field
func (*PooledFields) Int64 ¶ added in v1.1.0
func (pf *PooledFields) Int64(key string, value int64) *PooledFields
Int64 adds an int64 field
func (*PooledFields) Release ¶
func (pf *PooledFields) Release()
Release returns the underlying map to the pool
func (*PooledFields) String ¶
func (pf *PooledFields) String(key, value string) *PooledFields
String adds a string field
func (*PooledFields) Time ¶ added in v1.1.0
func (pf *PooledFields) Time(key string, value time.Time) *PooledFields
Time adds a time field (formats as RFC3339)
func (*PooledFields) ToMap ¶
func (pf *PooledFields) ToMap() map[string]any
ToMap returns the underlying map
type SensitiveDataMode ¶
type SensitiveDataMode int
SensitiveDataMode represents how to handle sensitive data
const ( MASK_SENSITIVE SensitiveDataMode = iota // Default: mask sensitive data SHOW_SENSITIVE // Show sensitive data (not recommended for production) )
type StringZField ¶
StringZField represents a string field with zero allocations
func ZString ¶
func ZString(key, value string) StringZField
ZString creates a zero-allocation string field
func (StringZField) IsPII ¶
func (f StringZField) IsPII() bool
func (StringZField) IsSensitive ¶
func (f StringZField) IsSensitive() bool
func (StringZField) WriteToEncoder ¶
func (f StringZField) WriteToEncoder(enc *ZeroAllocEncoder)
type TimeZField ¶
TimeZField represents a time field with zero allocations
func ZTime ¶
func ZTime(key string, value time.Time) TimeZField
ZTime creates a zero-allocation time field
func (TimeZField) IsPII ¶
func (f TimeZField) IsPII() bool
func (TimeZField) IsSensitive ¶
func (f TimeZField) IsSensitive() bool
func (TimeZField) WriteToEncoder ¶
func (f TimeZField) WriteToEncoder(enc *ZeroAllocEncoder)
type TimestampPrecision ¶ added in v1.2.0
type TimestampPrecision int
TimestampPrecision defines the precision level for timestamps
const ( NanosecondPrecision TimestampPrecision = iota MicrosecondPrecision MillisecondPrecision SecondPrecision )
func GetTimestampPrecision ¶ added in v1.2.0
func GetTimestampPrecision() TimestampPrecision
GetTimestampPrecision returns the current timestamp precision
func GetTimestampPrecisionConfig ¶ added in v1.2.0
func GetTimestampPrecisionConfig() TimestampPrecision
GetTimestampPrecisionConfig returns the current timestamp precision
func ParseTimestampPrecision ¶ added in v1.2.0
func ParseTimestampPrecision(precision string) TimestampPrecision
ParseTimestampPrecision parses timestamp precision from string
type WarnLogger ¶ added in v1.2.0
type WarnLogger struct{}
WarnLogger provides warn-level logging methods with clear, simple names
func (WarnLogger) Field ¶ added in v1.2.0
func (WarnLogger) Field(msg string, fields Fields)
Field logs a warn message with structured fields
func (WarnLogger) KeyValue ¶ added in v1.2.0
func (WarnLogger) KeyValue(msg string, keysAndValues ...interface{})
KeyValue logs a warn message with key-value pairs
func (WarnLogger) Msg ¶ added in v1.2.0
func (WarnLogger) Msg(message string)
Msg logs a simple warn message
func (WarnLogger) Pool ¶ added in v1.2.0
func (WarnLogger) Pool(msg string, fn func(*PooledFields))
Pool logs a warn message using memory-pooled fields
func (WarnLogger) StructuredFields ¶ added in v1.2.0
func (WarnLogger) StructuredFields(msg string, fields ...ZField)
StructuredFields logs a warn message with ultra-fast structured fields
type ZField ¶
type ZField interface {
WriteToEncoder(enc *ZeroAllocEncoder)
IsSensitive() bool
IsPII() bool
}
ZField represents a zero-allocation logging field
type ZeroAllocEncoder ¶
type ZeroAllocEncoder struct {
// contains filtered or unexported fields
}
ZeroAllocEncoder is a high-performance, zero-allocation JSON encoder