From 535d35f3f59439370be254f1b3dd5b642be8966e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 24 May 2020 01:23:37 -0400 Subject: [PATCH] Upgrade zap to the 1.0.0 release. The current version was pre-release! --- .gitmodules | 4 ++-- mailpopbox.go | 12 ++++++++++-- pop3.go | 6 +++--- pop3/conn.go | 6 +++--- pop3/conn_test.go | 2 +- server.go | 4 ++-- smtp.go | 6 +++--- smtp/conn.go | 6 +++--- smtp/conn_test.go | 2 +- vendor/github.com/uber-go/zap | 1 - vendor/{github.com/uber-go => go.uber.org}/atomic | 0 vendor/go.uber.org/zap | 1 + 12 files changed, 29 insertions(+), 21 deletions(-) delete mode 160000 vendor/github.com/uber-go/zap rename vendor/{github.com/uber-go => go.uber.org}/atomic (100%) create mode 160000 vendor/go.uber.org/zap diff --git a/.gitmodules b/.gitmodules index 3886bf1..b2c8b44 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "vendor/uber-go/zap"] - path = vendor/github.com/uber-go/zap + path = vendor/go.uber.org/zap url = https://github.com/uber-go/zap [submodule "vendor/github.com/uber-go/atomic"] - path = vendor/github.com/uber-go/atomic + path = vendor/go.uber.org/atomic url = https://github.com/uber-go/atomic diff --git a/mailpopbox.go b/mailpopbox.go index 0f1d156..05cdc37 100644 --- a/mailpopbox.go +++ b/mailpopbox.go @@ -11,7 +11,7 @@ import ( "fmt" "os" - "github.com/uber-go/zap" + "go.uber.org/zap" ) func main() { @@ -33,7 +33,15 @@ func main() { } configFile.Close() - log := zap.New(zap.NewTextEncoder()) + logConfig := zap.NewDevelopmentConfig() + logConfig.Development = false + logConfig.DisableStacktrace = true + logConfig.Level.SetLevel(zap.DebugLevel) + log, err := logConfig.Build() + if err != nil { + fmt.Fprintf(os.Stderr, "create logger: %v\n", err) + os.Exit(4) + } pop3 := runPOP3Server(config, log) smtp := runSMTPServer(config, log) diff --git a/pop3.go b/pop3.go index 638ac54..cada451 100644 --- a/pop3.go +++ b/pop3.go @@ -16,12 +16,12 @@ import ( "os" "path" - "github.com/uber-go/zap" + "go.uber.org/zap" "src.bluestatic.org/mailpopbox/pop3" ) -func runPOP3Server(config Config, log zap.Logger) <-chan ServerControlMessage { +func runPOP3Server(config Config, log *zap.Logger) <-chan ServerControlMessage { server := pop3Server{ config: config, controlChan: make(chan ServerControlMessage), @@ -34,7 +34,7 @@ func runPOP3Server(config Config, log zap.Logger) <-chan ServerControlMessage { type pop3Server struct { config Config controlChan chan ServerControlMessage - log zap.Logger + log *zap.Logger } func (server *pop3Server) run() { diff --git a/pop3/conn.go b/pop3/conn.go index 7f0f75d..13b1e82 100644 --- a/pop3/conn.go +++ b/pop3/conn.go @@ -13,7 +13,7 @@ import ( "net/textproto" "strings" - "github.com/uber-go/zap" + "go.uber.org/zap" ) type state int @@ -38,7 +38,7 @@ type connection struct { tp *textproto.Conn remoteAddr net.Addr - log zap.Logger + log *zap.Logger state line string @@ -46,7 +46,7 @@ type connection struct { user string } -func AcceptConnection(netConn net.Conn, po PostOffice, log zap.Logger) { +func AcceptConnection(netConn net.Conn, po PostOffice, log *zap.Logger) { log = log.With(zap.Stringer("client", netConn.RemoteAddr())) conn := connection{ po: po, diff --git a/pop3/conn_test.go b/pop3/conn_test.go index 204aece..3e48241 100644 --- a/pop3/conn_test.go +++ b/pop3/conn_test.go @@ -19,7 +19,7 @@ import ( "strings" "testing" - "github.com/uber-go/zap" + "go.uber.org/zap" ) func _fl(depth int) string { diff --git a/server.go b/server.go index 59e83c2..62750b6 100644 --- a/server.go +++ b/server.go @@ -12,7 +12,7 @@ import ( "os/signal" "syscall" - "github.com/uber-go/zap" + "go.uber.org/zap" ) type ServerControlMessage int @@ -22,7 +22,7 @@ const ( ServerControlRestart ) -func RunAcceptLoop(l net.Listener, c chan<- net.Conn, log zap.Logger) { +func RunAcceptLoop(l net.Listener, c chan<- net.Conn, log *zap.Logger) { for { conn, err := l.Accept() if err != nil { diff --git a/smtp.go b/smtp.go index 658a219..14ead8f 100644 --- a/smtp.go +++ b/smtp.go @@ -15,12 +15,12 @@ import ( "path" "strings" - "github.com/uber-go/zap" + "go.uber.org/zap" "src.bluestatic.org/mailpopbox/smtp" ) -func runSMTPServer(config Config, log zap.Logger) <-chan ServerControlMessage { +func runSMTPServer(config Config, log *zap.Logger) <-chan ServerControlMessage { server := smtpServer{ config: config, controlChan: make(chan ServerControlMessage), @@ -34,7 +34,7 @@ type smtpServer struct { config Config tlsConfig *tls.Config - log zap.Logger + log *zap.Logger controlChan chan ServerControlMessage } diff --git a/smtp/conn.go b/smtp/conn.go index 567666a..94db8a8 100644 --- a/smtp/conn.go +++ b/smtp/conn.go @@ -16,7 +16,7 @@ import ( "strings" "time" - "github.com/uber-go/zap" + "go.uber.org/zap" ) type state int @@ -40,7 +40,7 @@ type connection struct { esmtp bool tls *tls.ConnectionState - log zap.Logger + log *zap.Logger state line string @@ -50,7 +50,7 @@ type connection struct { rcptTo []mail.Address } -func AcceptConnection(netConn net.Conn, server Server, log zap.Logger) { +func AcceptConnection(netConn net.Conn, server Server, log *zap.Logger) { conn := connection{ server: server, tp: textproto.NewConn(netConn), diff --git a/smtp/conn_test.go b/smtp/conn_test.go index b8761cc..e36832e 100644 --- a/smtp/conn_test.go +++ b/smtp/conn_test.go @@ -17,7 +17,7 @@ import ( "testing" "time" - "github.com/uber-go/zap" + "go.uber.org/zap" ) func _fl(depth int) string { diff --git a/vendor/github.com/uber-go/zap b/vendor/github.com/uber-go/zap deleted file mode 160000 index 05dadc4..0000000 --- a/vendor/github.com/uber-go/zap +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 05dadc4e239529c50d6f730c17f0a3aaf35b64fd diff --git a/vendor/github.com/uber-go/atomic b/vendor/go.uber.org/atomic similarity index 100% rename from vendor/github.com/uber-go/atomic rename to vendor/go.uber.org/atomic diff --git a/vendor/go.uber.org/zap b/vendor/go.uber.org/zap new file mode 160000 index 0000000..4257c7c --- /dev/null +++ b/vendor/go.uber.org/zap @@ -0,0 +1 @@ +Subproject commit 4257c7cf05477d92ec25c31cfd3d60e89575f18a -- 2.43.5