e1.5.0 Log sink options added.

This commit is contained in:
2025-07-09 21:21:14 -04:00
parent ccbe65bf40
commit 43c98b08f9
9 changed files with 381 additions and 61 deletions

View File

@ -2,6 +2,7 @@
package log
import (
"io"
"os"
"strconv"
"strings"
@ -31,6 +32,7 @@ type State struct {
LoggedDrops atomic.Uint64 // Counter for dropped logs message already logged
ActiveLogChannel atomic.Value // stores chan logRecord
StdoutWriter atomic.Value // stores io.Writer (os.Stdout, os.Stderr, or io.Discard)
// Heartbeat statistics
HeartbeatSequence atomic.Uint64 // Counter for heartbeat sequence numbers
@ -40,6 +42,11 @@ type State struct {
TotalDeletions atomic.Uint64 // Counter for successful log deletions (cleanup/retention)
}
// sink is a wrapper around an io.Writer, atomic value type change workaround
type sink struct {
w io.Writer
}
// Init initializes or reconfigures the logger using the provided config.Config instance
func (l *Logger) Init(cfg *config.Config, basePath string) error {
if cfg == nil {
@ -220,4 +227,4 @@ func (l *Logger) Flush(timeout time.Duration) error {
case <-time.After(timeout):
return fmtErrorf("timeout waiting for flush confirmation (%v)", timeout)
}
}
}