mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
Replace github.com/rs/zerolog with go.uber.org/zap throughout the codebase to improve performance and provide better structured logging capabilities. Key changes: - Replace zerolog imports with zap and zapcore - Implement custom Logger wrapper in log.go to maintain zerolog-like API - Add LogEvent struct with chained methods (Str, Int, Err, Bool, etc.) - Update all logging calls to use the new zap-based wrapper - Replace JSON encoders with Console encoders for better readability Benefits: - Better performance with zap's optimized logging - Consistent structured logging across all components - Maintained zerolog-like API for easy migration - Proper field context preservation for debugging - Multi-core logging architecture for better output control All tests pass and build succeeds.
33 lines
626 B
Go
33 lines
626 B
Go
package cli
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
"github.com/Control-D-Inc/ctrld"
|
|
)
|
|
|
|
var logOutput strings.Builder
|
|
|
|
func TestMain(m *testing.M) {
|
|
// Create a custom writer that writes to logOutput
|
|
writer := zapcore.AddSync(&logOutput)
|
|
|
|
// Create zap encoder
|
|
encoderConfig := zap.NewDevelopmentEncoderConfig()
|
|
encoder := zapcore.NewConsoleEncoder(encoderConfig)
|
|
|
|
// Create core that writes to our string builder
|
|
core := zapcore.NewCore(encoder, writer, zap.DebugLevel)
|
|
|
|
// Create logger
|
|
l := zap.New(core)
|
|
|
|
mainLog.Store(&ctrld.Logger{Logger: l})
|
|
os.Exit(m.Run())
|
|
}
|