libtgvoip icon indicating copy to clipboard operation
libtgvoip copied to clipboard

Logs are written into stdout

Open zevlg opened this issue 6 years ago • 3 comments

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 ?

zevlg avatar Jan 10 '19 23:01 zevlg

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.

grishka avatar Jan 10 '19 23:01 grishka

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 avatar Jan 11 '19 00:01 zevlg

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

zevlg avatar Jan 14 '19 12:01 zevlg