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 | |
parent | Bug fixes (diff) | |
download | maild-b42568bf2223423fa0028255b26455b9f0560681.tar.gz maild-b42568bf2223423fa0028255b26455b9f0560681.tar.zst maild-b42568bf2223423fa0028255b26455b9f0560681.zip |
Update logging code
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | main.go | 12 |
3 files changed, 11 insertions, 7 deletions
@@ -4,7 +4,7 @@ go 1.23.4 require ( github.com/jackc/pgx/v5 v5.7.2 - go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250111202249-35d69905e2fc + go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250113062520-2daa71bfa256 ) require ( @@ -16,8 +16,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250111202249-35d69905e2fc h1:jYjxxslcbZSKmXT96FhRW//t0dx9LN54J4PeD6oXTQk= -go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250111202249-35d69905e2fc/go.mod h1:bOxuuGXA3UpbLb1lKohr2j2MVcGGLcqfAprGx9VCkMA= +go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250113062520-2daa71bfa256 h1:LCekcmEfZRfuuLMKUMT2TCgdXQRPIjxalibQIzHjzIo= +go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250113062520-2daa71bfa256/go.mod h1:bOxuuGXA3UpbLb1lKohr2j2MVcGGLcqfAprGx9VCkMA= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= @@ -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()) } }() } |