core: replace zap with logtree

Test Plan: Effective refactor. Only tests that could be affected are e2e tests that should continue to run, because we still are logging into the qemu console, even if differently.

X-Origin-Diff: phab/D642
GitOrigin-RevId: 0f12b1bc985af08a3cc269569273184321763e4b
diff --git a/core/internal/consensus/BUILD.bazel b/core/internal/consensus/BUILD.bazel
index 74b70d9..b8b45a7 100644
--- a/core/internal/consensus/BUILD.bazel
+++ b/core/internal/consensus/BUILD.bazel
@@ -14,8 +14,6 @@
         "@io_etcd_go_etcd//clientv3/namespace:go_default_library",
         "@io_etcd_go_etcd//embed:go_default_library",
         "@org_uber_go_atomic//:go_default_library",
-        "@org_uber_go_zap//:go_default_library",
-        "@org_uber_go_zap//zapcore:go_default_library",
     ],
 )
 
@@ -28,6 +26,5 @@
         "//core/internal/localstorage:go_default_library",
         "//core/internal/localstorage/declarative:go_default_library",
         "//golibs/common:go_default_library",
-        "@org_uber_go_zap//:go_default_library",
     ],
 )
diff --git a/core/internal/consensus/consensus.go b/core/internal/consensus/consensus.go
index 94d84b2..1403964 100644
--- a/core/internal/consensus/consensus.go
+++ b/core/internal/consensus/consensus.go
@@ -43,8 +43,6 @@
 	"go.etcd.io/etcd/clientv3/namespace"
 	"go.etcd.io/etcd/embed"
 	"go.uber.org/atomic"
-	"go.uber.org/zap"
-	"go.uber.org/zap/zapcore"
 
 	"git.monogon.dev/source/nexantic.git/core/internal/common"
 	"git.monogon.dev/source/nexantic.git/core/internal/common/supervisor"
@@ -157,13 +155,9 @@
 		cfg.InitialCluster = s.config.InitialCluster
 	}
 
-	logger := supervisor.Logger(ctx)
+	// TODO(q3k): pipe logs from etcd to supervisor.RawLogger via a file.
 	cfg.Logger = DefaultLogger
-	cfg.ZapLoggerBuilder = embed.NewZapCoreLoggerBuilder(
-		logger.With(zap.String("component", "etcd")).WithOptions(zap.IncreaseLevel(zapcore.WarnLevel)),
-		logger.Core(),
-		nil,
-	)
+	cfg.LogOutputs = []string{"stderr"}
 
 	return cfg, nil
 }
@@ -354,9 +348,9 @@
 			// Luckily etcd already does sanity checks internally and will refuse to promote nodes that aren't
 			// connected or are still behind on transactions.
 			if _, err := st.etcd.Server.PromoteMember(ctx, uint64(member.ID)); err != nil {
-				supervisor.Logger(ctx).Info("Failed to promote consensus node", zap.String("node", member.Name), zap.Error(err))
+				supervisor.Logger(ctx).Infof("Failed to promote consensus node %s: %v", member.Name, err)
 			} else {
-				supervisor.Logger(ctx).Info("Promoted new consensus node", zap.String("node", member.Name))
+				supervisor.Logger(ctx).Infof("Promoted new consensus node %s", member.Name)
 			}
 		}
 	}
diff --git a/core/internal/consensus/consensus_test.go b/core/internal/consensus/consensus_test.go
index 6e225e0..a308cf4 100644
--- a/core/internal/consensus/consensus_test.go
+++ b/core/internal/consensus/consensus_test.go
@@ -26,8 +26,6 @@
 	"testing"
 	"time"
 
-	"go.uber.org/zap"
-
 	"git.monogon.dev/source/nexantic.git/core/internal/common/supervisor"
 	"git.monogon.dev/source/nexantic.git/core/internal/localstorage"
 	"git.monogon.dev/source/nexantic.git/core/internal/localstorage/declarative"
@@ -38,7 +36,6 @@
 	ctx    context.Context
 	ctxC   context.CancelFunc
 	root   *localstorage.Root
-	logger *zap.Logger
 	tmpdir string
 }
 
@@ -56,13 +53,10 @@
 	os.MkdirAll(root.Data.Etcd.FullPath(), 0700)
 	os.MkdirAll(root.Ephemeral.Consensus.FullPath(), 0700)
 
-	logger, _ := zap.NewDevelopment()
-
 	return &boilerplate{
 		ctx:    ctx,
 		ctxC:   ctxC,
 		root:   root,
-		logger: logger,
 		tmpdir: tmp,
 	}
 }
@@ -99,7 +93,7 @@
 		Port:           common.MustConsume(common.AllocateTCPPort()),
 	})
 
-	supervisor.New(b.ctx, b.logger, etcd.Run)
+	supervisor.New(b.ctx, etcd.Run)
 	waitEtcd(t, etcd)
 
 	kv := etcd.KV("foo", "bar")
@@ -124,7 +118,7 @@
 		ListenHost:     "127.0.0.1",
 		Port:           common.MustConsume(common.AllocateTCPPort()),
 	})
-	supervisor.New(b.ctx, b.logger, etcd.Run)
+	supervisor.New(b.ctx, etcd.Run)
 	waitEtcd(t, etcd)
 
 	id, name, err := etcd.MemberInfo(b.ctx)
@@ -170,7 +164,7 @@
 			Port:           common.MustConsume(common.AllocateTCPPort()),
 		})
 		ctx, ctxC := context.WithCancel(b.ctx)
-		supervisor.New(ctx, b.logger, etcd.Run)
+		supervisor.New(ctx, etcd.Run)
 		waitEtcd(t, etcd)
 		kv := etcd.KV("foo", "bar")
 		if new {
@@ -215,7 +209,7 @@
 		ListenHost:     "127.0.0.1",
 		Port:           common.MustConsume(common.AllocateTCPPort()),
 	})
-	supervisor.New(b.ctx, b.logger, etcd.Run)
+	supervisor.New(b.ctx, etcd.Run)
 	waitEtcd(t, etcd)
 
 	etcd.stateMu.Lock()