FS#9734 - logf add log level

Attached to Project: Rockbox
Opened by Yoshihisa Uchida (Uchida) - Wednesday, 31 December 2008, 15:02 GMT
Task Type Patches
Category Operating System/Drivers
Status Unconfirmed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


logf() 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.


Just the log where log level is LOG_LEVEL_WARN or LOG_LEVEL_ERROR is output.
This task depends upon

Comment by Maurus Cuelenaere (mcuelenaere) - Thursday, 01 January 2009, 23:44 GMT
I was thinking of implementing the same thing, but apparently you're faster :)

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)