Bump the version to 2.1.0.
[mailpopbox.git] / mailpopbox.go
index 2966d4fc619019b41ceae242f4b850108b9789e4..62bbf71a34a03e4fb07cfa2a6d868f0e6f750b98 100644 (file)
@@ -1,3 +1,9 @@
+// mailpopbox
+// Copyright 2020 Blue Static <https://www.bluestatic.org>
+// This program is free software licensed under the GNU General Public License,
+// version 3.0. The full text of the license can be found in LICENSE.txt.
+// SPDX-License-Identifier: GPL-3.0-only
+
 package main
 
 import (
@@ -5,7 +11,7 @@ import (
        "fmt"
        "os"
 
-       "github.com/uber-go/zap"
+       "go.uber.org/zap"
 )
 
 func main() {
@@ -14,6 +20,11 @@ func main() {
                os.Exit(1)
        }
 
+       if os.Args[1] == "version" {
+               fmt.Print(versionString)
+               os.Exit(0)
+       }
+
        configFile, err := os.Open(os.Args[1])
        if err != nil {
                fmt.Fprintf(os.Stderr, "config file: %s\n", err)
@@ -27,7 +38,17 @@ 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)
+       }
+
+       log.Info("starting mailpopbox", zap.String("hostname", config.Hostname))
 
        pop3 := runPOP3Server(config, log)
        smtp := runSMTPServer(config, log)