grishka / libtgvoip

VoIP library for Telegram clients
The Unlicense
387 stars 156 forks source link

Logs are written into stdout #65

Open zevlg opened 5 years ago

zevlg commented 5 years ago

I've noticed that under linux logs are written into stdout. If some program links to libtgvoip and uses stdout for its own purpose, there is no way to separate ordinary output from the program and logging output made by libtgvoip.

Is not it a good practice for libraries to write logs/diagnostics to stderr instead of stdout ?

grishka commented 5 years ago

I'm really not sure about this one as I've seen libraries writing logs to stdout. There is a define to control this (TGVOIP_LOG_VERBOSITY=0..5) where 5 is most verbose and 0 is no logging. You're probably right that there needs to be a way to control stdout/logcat/NSLog logging separately from file logging (to a file you optionally specify in config) or even to specify a custom logging function.

zevlg commented 5 years ago

Yeah, I’m currently disabled logging via TGVOIP_LOG_VERBOSITY, but having active logs from tgvoip is very helpful. Custom log func sounds great! Or at least having some custom FILE* to write logs to

zevlg commented 5 years ago

I like tdlib's approach for logging: it writes logs into specified file and rotates it after exceeding specified size. It also has logging level customizable at runtime