aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-13 14:14:44 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-13 14:44:05 +0800
commitb42568bf2223423fa0028255b26455b9f0560681 (patch)
tree8ec3723768c07742098a2c820ac57a916cfbab75 /main.go
parentBug fixes (diff)
downloadmaild-b42568bf2223423fa0028255b26455b9f0560681.tar.gz
maild-b42568bf2223423fa0028255b26455b9f0560681.tar.zst
maild-b42568bf2223423fa0028255b26455b9f0560681.zip
Update logging code
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.go b/main.go
index f1c28ba..bf503f4 100644
--- a/main.go
+++ b/main.go
@@ -18,27 +18,31 @@ func main() {
err := load_config(*config_path)
if err != nil {
- panic(err)
+ clog.Fatal(1, "Configuration file not found at "+*config_path)
}
listener, err := net.Listen(config.MX.Net, config.MX.Addr)
if err != nil {
- panic(err)
+ clog.Fatal(1, "MX: Cannot listen: "+err.Error())
}
defer listener.Close()
+ clog.Info("MX: Listening via " + config.MX.Net + " on " + config.MX.Addr)
for {
conn, err := listener.Accept()
if err != nil {
- panic(err)
+ clog.Error("MX: Cannot accept connection: "+err.Error())
}
+ clog.Info("MX: Accepted connection from " + conn.RemoteAddr().String())
go func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := handle_mx_recv_conn(ctx, conn)
if err != nil && !errors.Is(err, io.EOF) {
- clog.Error("connection handler returned error", "err", err)
+ clog.Error("MX: Connection handler for " + conn.RemoteAddr().String() + " returned error: " + err.Error())
+ } else {
+ clog.Error("MX: Connection handler for " + conn.RemoteAddr().String() + " returned error: " + err.Error())
}
}()
}