From 998371d5eba4d21ac45ae9e8862a76ba898a595f Mon Sep 17 00:00:00 2001 From: mAdkins Date: Mon, 26 Feb 2024 06:11:33 -0800 Subject: [PATCH 1/5] Use proposed new zerolog function to fix breakage --- go.mod | 10 +++++----- go.sum | 3 +++ zerolog.go | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f2c9ded..7aa3451 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,14 @@ module github.com/phsym/zeroslog go 1.21 -require github.com/rs/zerolog v1.31.0 +require ( + github.com/rs/zerolog v1.32.0 +) + +replace github.com/rs/zerolog => /home/marc/work/go/src/github.com/madkins23/zerolog require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect golang.org/x/sys v0.12.0 // indirect ) - -// This version of rs/zerolog breaks phsym/zeroslog -exclude github.com/rs/zerolog v1.32.0 - diff --git a/go.sum b/go.sum index 7349483..6f225d6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/madkins23/zerolog v0.0.0-20240204145057-bd2896587dac/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -9,6 +10,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= +github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= diff --git a/zerolog.go b/zerolog.go index 3807b2c..5c21af9 100644 --- a/zerolog.go +++ b/zerolog.go @@ -131,7 +131,7 @@ func (h *Handler) Handle(_ context.Context, rec slog.Record) error { func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler { return &Handler{ opts: h.opts, - logger: mapAttrs(h.logger.With(), attrs...).Logger(), + logger: mapAttrs(zerolog.NewContextWithResetLogger(h.logger), attrs...).Logger(), } } @@ -139,7 +139,7 @@ func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler { func (h *Handler) WithGroup(name string) slog.Handler { return &groupHandler{ parent: h, - ctx: zerolog.Context{}, + ctx: zerolog.NewContextWithResetLogger(h.logger), name: strings.TrimSpace(name), } } @@ -182,7 +182,7 @@ func (h *groupHandler) Handle(ctx context.Context, rec slog.Record) error { func (h *groupHandler) WithAttrs(attrs []slog.Attr) slog.Handler { return &groupHandler{ parent: h.parent, - ctx: mapAttrs(h.ctx.Logger().With(), attrs...), + ctx: mapAttrs(zerolog.NewContextWithResetLogger(h.ctx.Logger()), attrs...), name: h.name, } } @@ -191,7 +191,7 @@ func (h *groupHandler) WithAttrs(attrs []slog.Attr) slog.Handler { func (h *groupHandler) WithGroup(name string) slog.Handler { return &groupHandler{ parent: h, - ctx: zerolog.Context{}, + ctx: zerolog.NewContextWithResetLogger(h.ctx.Logger()), name: name, } } From b3079de1851a5090166a4e58e1e16742693de75e Mon Sep 17 00:00:00 2001 From: mAdkins Date: Sun, 3 Mar 2024 07:07:10 -0800 Subject: [PATCH 2/5] Testing against proposed fix to zerolog --- zerolog.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zerolog.go b/zerolog.go index 5c21af9..e1c7cd6 100644 --- a/zerolog.go +++ b/zerolog.go @@ -131,7 +131,7 @@ func (h *Handler) Handle(_ context.Context, rec slog.Record) error { func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler { return &Handler{ opts: h.opts, - logger: mapAttrs(zerolog.NewContextWithResetLogger(h.logger), attrs...).Logger(), + logger: mapAttrs(h.logger.With().Reset(), attrs...).Logger(), } } @@ -139,7 +139,7 @@ func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler { func (h *Handler) WithGroup(name string) slog.Handler { return &groupHandler{ parent: h, - ctx: zerolog.NewContextWithResetLogger(h.logger), + ctx: h.logger.With().Reset(), name: strings.TrimSpace(name), } } @@ -182,7 +182,7 @@ func (h *groupHandler) Handle(ctx context.Context, rec slog.Record) error { func (h *groupHandler) WithAttrs(attrs []slog.Attr) slog.Handler { return &groupHandler{ parent: h.parent, - ctx: mapAttrs(zerolog.NewContextWithResetLogger(h.ctx.Logger()), attrs...), + ctx: mapAttrs(h.ctx.Logger().With().Reset(), attrs...), name: h.name, } } @@ -191,7 +191,7 @@ func (h *groupHandler) WithAttrs(attrs []slog.Attr) slog.Handler { func (h *groupHandler) WithGroup(name string) slog.Handler { return &groupHandler{ parent: h, - ctx: zerolog.NewContextWithResetLogger(h.ctx.Logger()), + ctx: h.ctx.Logger().With().Reset(), name: name, } } From a1a446d9d5839a8caeab6711a2cef474970bfe87 Mon Sep 17 00:00:00 2001 From: mAdkins Date: Sun, 3 Mar 2024 07:38:41 -0800 Subject: [PATCH 3/5] Remove redundant Reset() after looking into GroupInline warning fix --- zerolog.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zerolog.go b/zerolog.go index e1c7cd6..6f201c3 100644 --- a/zerolog.go +++ b/zerolog.go @@ -131,7 +131,7 @@ func (h *Handler) Handle(_ context.Context, rec slog.Record) error { func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler { return &Handler{ opts: h.opts, - logger: mapAttrs(h.logger.With().Reset(), attrs...).Logger(), + logger: mapAttrs(h.logger.With(), attrs...).Logger(), } } From 6fab93a7e7a909f70b2de6e2ca2d819d24157f1b Mon Sep 17 00:00:00 2001 From: mAdkins Date: Wed, 6 Mar 2024 09:41:43 -0800 Subject: [PATCH 4/5] Test v1.32.0 fix against unreleased zerolog master branch after PR#575 is merged into zerolog --- go.mod | 6 +----- go.sum | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 7aa3451..078ef2b 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,7 @@ module github.com/phsym/zeroslog go 1.21 -require ( - github.com/rs/zerolog v1.32.0 -) - -replace github.com/rs/zerolog => /home/marc/work/go/src/github.com/madkins23/zerolog +require github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b require ( github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 6f225d6..9956be4 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,5 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/madkins23/zerolog v0.0.0-20240204145057-bd2896587dac/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -8,10 +7,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b h1:eUxavk8hnzV7Kt3bnsnjOUyBjLSaiS1OCocMJKXO9+M= +github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= From a54d659a8a521abab72c3e584dbdf869faa4f29b Mon Sep 17 00:00:00 2001 From: mAdkins Date: Thu, 23 May 2024 06:47:07 -0700 Subject: [PATCH 5/5] Update rs/zerolog dependency to 1.33.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 078ef2b..c8d0a51 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/phsym/zeroslog go 1.21 -require github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b +require github.com/rs/zerolog v1.33.0 require ( github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 9956be4..98afda4 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b h1:eUxavk8hnzV7Kt3bnsnjOUyBjLSaiS1OCocMJKXO9+M= -github.com/rs/zerolog v1.32.1-0.20240306065720-74cf37a3965b/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=