refactor: migrate from zerolog to zap logging library

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.
This commit is contained in:
Cuong Manh Le
2025-07-21 19:50:43 +07:00
committed by Cuong Manh Le
parent 016c566307
commit d41334c66f
15 changed files with 400 additions and 135 deletions
+3 -3
View File
@@ -9,10 +9,10 @@ import (
"runtime"
"syscall"
"github.com/rs/zerolog"
"github.com/Control-D-Inc/ctrld"
)
func selfUninstall(p *prog, logger zerolog.Logger) {
func selfUninstall(p *prog, logger *ctrld.Logger) {
if runtime.GOOS == "linux" {
selfUninstallLinux(p, logger)
}
@@ -37,7 +37,7 @@ func selfUninstall(p *prog, logger zerolog.Logger) {
os.Exit(0)
}
func selfUninstallLinux(p *prog, logger zerolog.Logger) {
func selfUninstallLinux(p *prog, logger *ctrld.Logger) {
if uninstallInvalidCdUID(p, logger, true) {
logger.Warn().Msgf("service was uninstalled because device %q does not exist", cdUID)
os.Exit(0)