e1.0.0 Initial commit, restructured and refactored logger package, used config package for configuration management.

This commit is contained in:
2025-04-22 11:29:34 -04:00
commit b78da2b449
15 changed files with 2621 additions and 0 deletions

55
cmd/reconfig/main.go Normal file
View File

@ -0,0 +1,55 @@
package main
import (
"fmt"
"sync/atomic"
"time"
"github.com/LixenWraith/log"
)
// Simulate rapid reconfiguration
func main() {
var count atomic.Int64
// Initialize the logger with defaults first
err := log.InitWithDefaults()
if err != nil {
fmt.Printf("Initial Init error: %v\n", err)
return
}
// Log something constantly
go func() {
for i := 0; ; i++ {
log.Info("Test log", i)
count.Add(1)
time.Sleep(time.Millisecond)
}
}()
// Trigger multiple reconfigurations rapidly
for i := 0; i < 10; i++ {
// Use different buffer sizes to trigger channel recreation
bufSize := fmt.Sprintf("buffer_size=%d", 100*(i+1))
err := log.InitWithDefaults(bufSize)
if err != nil {
fmt.Printf("Init error: %v\n", err)
}
// Minimal delay between reconfigurations
time.Sleep(10 * time.Millisecond)
}
// Check if we see any inconsistency
time.Sleep(500 * time.Millisecond)
fmt.Printf("Total logs attempted: %d\n", count.Load())
// Gracefully shut down the logger
err = log.Shutdown(time.Second)
if err != nil {
fmt.Printf("Shutdown error: %v\n", err)
}
// Check for any error messages in the log files
// or dropped log count
}