This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#9734 - logf add log level
Attached to Project:
Rockbox
Opened by Yoshihisa Uchida (Uchida) - Wednesday, 31 December 2008, 16:02 GMT+2
Opened by Yoshihisa Uchida (Uchida) - Wednesday, 31 December 2008, 16:02 GMT+2
|
Detailslogf() is used in order to output the log of the use which differs "info", "worning" or "error".
Log level is added to logf() by applying the patch, it becomes the way which understands it is some kind of log. debug log: logf(LOG_LEVEL_DEBUG, ...) Simply: debugf(...) info log: logf(LOG_LEVEL_INFO, ...) Simply: logf(...) warning log: logf(LOG_LEVEL_WARN, ...) Simply: warnf(...) error log: logf(LOG_LEVEL_ERROR, ...) Simply: errorf(...) In addition, it added function set_output_log_level(int level), it tried to be able to set the level of the log which is output. eg. set_output_log_level(LOG_PREFIX_WARN); Just the log where log level is LOG_LEVEL_WARN or LOG_LEVEL_ERROR is output. |
This task depends upon
I think your implementation is quite good, apart from one thing: you add the logf ouput level prefix directly to the to-be-logged string. I wouldn't do that, but use the MAX_LOGF_ENTRY'ed byte at every line to indicate what the output level is (like setting bit 7 means Warning, bit 6 means Error, etc).
That way you save some space + there's an easier and faster way to filter out lower level log messages (e.g. only display messages with bit X set).
Also, why do you use rb->warnf(), rb->errorf() etc when you don't add them to the plugin struct? (I wouldn't add separate function calls either, just extend logf(const char *fmt, ...) to logf(int level, const char *fmt, ...) (like you did) and use macro's to do WARNF(), ERRORF() etc)