Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: auto initialize logger (#1442)

Yilong Li63585df59806
diff --git a/bin/bb/cmd/root.go b/bin/bb/cmd/root.go
index 8ae9108a5c..53147e68bb 100644
--- a/bin/bb/cmd/root.go
+++ b/bin/bb/cmd/root.go
@@ -23,7 +23,6 @@ func NewRootCmd() *cobra.Command {
// Execute is the execute command for root command.
func Execute() (err error) {
- log.Init()
defer log.Sync()
return NewRootCmd().Execute()
}
diff --git a/bin/bb/cmd/root_test.go b/bin/bb/cmd/root_test.go
index 6ce4cd21f7..ad4d9a80d0 100644
--- a/bin/bb/cmd/root_test.go
+++ b/bin/bb/cmd/root_test.go
@@ -39,7 +39,6 @@ type testTable struct {
}
func tableTest(t *testing.T, tables []testTable) {
- log.Init()
log.SetLevel(zap.DebugLevel)
t.Helper()
for _, tc := range tables {
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go
index 958586b6b6..1475bff071 100644
--- a/bin/server/cmd/root.go
+++ b/bin/server/cmd/root.go
@@ -151,7 +151,6 @@ func checkDataDir() error {
}
func start() {
- log.Init()
if flags.debug {
log.SetLevel(zap.DebugLevel)
}
diff --git a/common/log/logger.go b/common/log/logger.go
index 42a2f6cfd6..6be51c57e3 100644
--- a/common/log/logger.go
+++ b/common/log/logger.go
@@ -15,11 +15,8 @@ var (
gLevel zap.AtomicLevel
)
-// Init initializes the global console logger.
-func Init() {
- if gl != nil {
- return
- }
+// Initializes the global console logger.
+func init() {
gLevel = zap.NewAtomicLevelAt(zap.InfoLevel)
gl = zap.New(zapcore.NewCore(
zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig()),
diff --git a/store/pg_engine_test.go b/store/pg_engine_test.go
index ebea391c4a..59777c50b1 100644
--- a/store/pg_engine_test.go
+++ b/store/pg_engine_test.go
@@ -143,7 +143,6 @@ var (
)
func TestMigrationCompatibility(t *testing.T) {
- log.Init()
log.SetLevel(zap.DebugLevel)
pgDir := t.TempDir()
pgInstance, err := postgres.Install(path.Join(pgDir, "resource"), path.Join(pgDir, "data"), pgUser)
diff --git a/tests/tests.go b/tests/tests.go
index 0a1502aa2e..ce061c623c 100644
--- a/tests/tests.go
+++ b/tests/tests.go
@@ -141,7 +141,6 @@ func getTestPort(testName string) int {
// StartServerWithExternalPg starts the main server with external Postgres.
func (ctl *controller) StartServerWithExternalPg(ctx context.Context, dataDir string, port int, pgUser, pgURL string) error {
- log.Init()
log.SetLevel(zap.DebugLevel)
profile := cmd.GetTestProfileWithExternalPg(dataDir, port, pgUser, pgURL)
server, err := server.NewServer(ctx, profile)
@@ -156,7 +155,6 @@ func (ctl *controller) StartServerWithExternalPg(ctx context.Context, dataDir st
// StartServer starts the main server with embed Postgres.
func (ctl *controller) StartServer(ctx context.Context, dataDir string, port int) error {
// start main server.
- log.Init()
log.SetLevel(zap.DebugLevel)
profile := cmd.GetTestProfile(dataDir, port)
server, err := server.NewServer(ctx, profile)