diff options
author | Runxi Yu <me@runxiyu.org> | 2025-01-13 14:14:44 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-01-13 14:44:05 +0800 |
commit | b42568bf2223423fa0028255b26455b9f0560681 (patch) | |
tree | 8ec3723768c07742098a2c820ac57a916cfbab75 /main.go | |
parent | Bug fixes (diff) | |
download | maild-b42568bf2223423fa0028255b26455b9f0560681.tar.gz maild-b42568bf2223423fa0028255b26455b9f0560681.tar.zst maild-b42568bf2223423fa0028255b26455b9f0560681.zip |
Update logging code
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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()) } }() } |