v0.1.9 kv flag added, unix and nofs build tags, heartbeat and rotation filename and test update

This commit is contained in:
2026-08-01 05:09:51 -04:00
parent 24b7deebdb
commit 2af9af2359
15 changed files with 873 additions and 481 deletions
+15 -3
View File
@@ -7,8 +7,10 @@ import (
// Builder provides a fluent API for building logger configurations
// It wraps a Config instance and provides chainable methods for setting values
type Builder struct {
cfg *Config
err error // Accumulate errors for deferred handling
err error // Accumulate errors for deferred handling
cfg *Config
ctxTag string
ctxVals []string
}
// NewBuilder creates a new configuration builder with default values
@@ -18,6 +20,13 @@ func NewBuilder() *Builder {
}
}
// ContextKeys names the record keys for Context values
func (b *Builder) ContextKeys(tag string, vals ...string) *Builder {
b.ctxTag = tag
b.ctxVals = vals
return b
}
// Build creates a new Logger instance with the specified configuration
func (b *Builder) Build() (*Logger, error) {
if b.err != nil {
@@ -31,6 +40,9 @@ func (b *Builder) Build() (*Logger, error) {
if err := logger.ApplyConfig(b.cfg); err != nil {
return nil, err
}
if b.ctxTag != "" || len(b.ctxVals) > 0 {
logger.SetContextKeys(b.ctxTag, b.ctxVals...)
}
return logger, nil
}
@@ -249,4 +261,4 @@ func (b *Builder) EnableConsole(enable bool) *Builder {
// defer logger.Shutdown()
// logger.Info("Logger initialized successfully")
//
// }
// }