From 24afe119e836a7c52803400a7caae63b44b07c42 Mon Sep 17 00:00:00 2001 From: Keepers Date: Mon, 4 Nov 2024 15:57:51 -0700 Subject: [PATCH] remove clog's singleton hook context and deployment management is going to get too complicated to assume we can always reference a global singleton outside of the ctx. --- clog/builder_test.go | 20 -------------------- clog/logger.go | 21 --------------------- 2 files changed, 41 deletions(-) diff --git a/clog/builder_test.go b/clog/builder_test.go index 57af2ee..db53db1 100644 --- a/clog/builder_test.go +++ b/clog/builder_test.go @@ -34,26 +34,6 @@ func (suite *BuilderUnitSuite) TestBuilder() { return Ctx(ctx) }, }, - { - name: "singleton", - init: func(ctx context.Context) context.Context { - return Init( - ctx, - Settings{}.EnsureDefaults()) - }, - bldr: func(ctx context.Context) *builder { - return Singleton() - }, - }, - { - name: "singleton, no prior init", - init: func(ctx context.Context) context.Context { - return ctx - }, - bldr: func(ctx context.Context) *builder { - return Singleton() - }, - }, } for _, test := range table { diff --git a/clog/logger.go b/clog/logger.go index 4084505..1050b45 100644 --- a/clog/logger.go +++ b/clog/logger.go @@ -6,7 +6,6 @@ import ( "sync" "time" - "github.com/alcionai/clues" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -210,26 +209,6 @@ func CtxErr(ctx context.Context, err error) *builder { return nb } -// Singleton is a shorthand for .Ctx(context.Background()). IE: it'll use the singleton -// logger directly; building one if necessary. You should avoid this and use .Ctx or -// .CtxErr if possible. Likelihood is that you're somewhere deep in a func chain that -// doesn't accept a ctx, and you still want to add a quick log; maybe for debugging purposes. -// -// That's fine! Everything should work great. -// -// Unless you call this before initialization. Then it'll panic. We do want you to init -// the logger first, else you'll potentially lose these logs due different buffers. -func Singleton() *builder { - if cloggerton == nil { - panic(clues.New("clog singleton requires prior initialization")) - } - - return &builder{ - ctx: context.Background(), - zsl: cloggerton.zsl, - } -} - // Flush writes out all buffered logs. // Probably good to do before shutting down whatever instance // had initialized the singleton.