forgottenserver
forgottenserver copied to clipboard
Logging subsystem
There are a lot of inconsistencies in the way we present logs to the user. In order to make logging uniform throughout the codebase we need a unified, preferably typesafe logging subsystem. On POSIX compliant systems the logs should be directed either to stdout or to syslog()
. The logging subsystem should provide 3 log levels:
- Info (global events like server reload or player log in/log out)
- Error/Warning (maybe split these?) - when something went wrong
- Debug - by default disabled, can be enabled with a cmake flag (not sure if we need this, GDB is awesome)
I have this small, nice library that outputs colored, namespaced logging: https://gist.github.com/ranisalt/639a4ab5717937c0bd349e95f8cb9dc7
I could improve it in order to add to TFS. It's header only and works this way:
logger << "Some message " << some_var << 123 << logger::endl;
And it outputs the full line with the namespace at the beginning.
👍 for colored output
Did it when bored and things looks so much better now (only on otserv.cpp though)
Not sure how the coloring of logs works with syslog/journald (would be nice if you could daemonize TFS using systemd and view its logs using journalctl
.
https://github.com/securmk/TFSLogger
I've created this while I was bored. It has some ugly parts but I'm just too lazy to solve them. It's based in original CIP files' logger.
I'm looking through old issues today and coincidentally it's what I've been working on today https://github.com/Zbizu/forgottenserver/commit/ec2cf008dd3aca891745938b32af37b1c398327b https://github.com/Zbizu/forgottenserver/commit/da311f22a353a74ec8ee6aab3e73805758040bab
let me know if you're interested