Commit Graph

4 Commits

Author SHA1 Message Date
Moritz Poldrack 5ca6022d00 lint: ensure errors are at least logged (errcheck)
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:57:57 +02:00
Robin Jarry a1f779ccc9 logging: add logger system with levels
The built-in logging system is rather basic. Implement a multi-level
logger to ease interpreting the logs. Configure the loggers with
prefixes and microsecond precision for timestamps.

Also, prefix the messages with the source file name and line number.
Because of this, enabling the logs has a performance cost. They will
only be enabled when redirecting aerc stdout to a file.

Here is an example output:

DEBUG 2022/07/20 12:52:34.536190 worker.go:45: PostAction *types.FetchDirectoryContents
DEBUG 2022/07/20 12:52:34.536329 worker.go:92: ProcessAction *types.FetchDirectoryContents(2417)
DEBUG 2022/07/20 12:52:34.536407 idler.go:159: idler (0xc00017c000) [idle:false,wait:false] =>(idle) [debounce]
INFO  2022/07/20 12:52:34.536432 threadbuilder.go:59: 130 threads created in 220.796µs
DEBUG 2022/07/20 12:52:34.536449 worker.go:75: ProcessMessage *types.DirectoryInfo(2416)
DEBUG 2022/07/20 12:52:34.536453 idler.go:159: idler (0xc00017c000) [idle:false,wait:false] <=(idle)
DEBUG 2022/07/20 12:52:34.536459 worker.go:45: PostAction *types.FetchDirectoryContents
INFO  2022/07/20 12:52:34.536470 open.go:30: Fetching UID list
INFO  2022/07/20 12:52:34.536689 threadbuilder.go:59: 130 threads created in 201.635µs

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-23 22:52:10 +02:00
Moritz Poldrack 4821425933 fix typo in panic logger
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-07-10 20:36:24 +02:00
Moritz Poldrack ae83373fa6 logging: added a log on panic
Since panics still regularly "destroy" the terminal, it is hard to get a
stack trace for panics you do not anticipate. This commit adds a panic
handler that automatically creates a logfile inside the current working
directory.

It has to be added to every goroutine that is started and will repair
the terminal on a panic.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23 20:56:09 +01:00