Include handler errors in the log file #173

Closed
opened 2026-01-19 18:29:17 +00:00 by michael · 3 comments
Owner

Originally created by @JustAnotherArchivist on GitHub.

I realised today that many messages only get logged to stderr, not to the log file. In particular, this includes all errors in the handlers, e.g. errors on reading from the storage (i.e. the log.Printf calls in handlers.go). I'd like to suggest having those both on stderr and in the log file (if one is specified).

Originally created by @JustAnotherArchivist on GitHub. I realised today that many messages only get logged to stderr, not to the log file. In particular, this includes all errors in the handlers, e.g. errors on reading from the storage (i.e. the `log.Printf` calls in `handlers.go`). I'd like to suggest having those both on stderr and in the log file (if one is specified).
Author
Owner

@paolafrancesca commented on GitHub:

I will check @JustAnotherArchivist , thanks for reporting.

@paolafrancesca commented on GitHub: I will check @JustAnotherArchivist , thanks for reporting.
Author
Owner

@stefanbenten commented on GitHub:

I would suggest to chose either stderr or log, but not both.

@stefanbenten commented on GitHub: I would suggest to chose either stderr or log, but not both.
Author
Owner

@paolafrancesca commented on GitHub:

We should only rely on the logger instantiated in the cmd package: https://github.com/dutchcoders/transfer.sh/blob/master/cmd/cmd.go#L294

This will either use stdout or the log file if set (49c6d7ee4f/server/server.go (L160-L176))

The calls to log.Printf etc should be replaced by logger.Printf etc

@paolafrancesca commented on GitHub: We should only rely on the logger instantiated in the cmd package: https://github.com/dutchcoders/transfer.sh/blob/master/cmd/cmd.go#L294 This will either use stdout or the log file if set (https://github.com/dutchcoders/transfer.sh/blob/49c6d7ee4fda62d6334b87b1a9c8c1c6adea8018/server/server.go#L160-L176) The calls to `log.Printf` etc should be replaced by `logger.Printf` etc
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#173