Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1c67b41 in mainline


Ignore:
Timestamp:
2012-08-16T11:20:24Z (9 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
eab3d04
Parents:
04da852
Message:

Use log level names when printing instead of numbers

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/log.c

    r04da852 r1c67b41  
    4646static const char *log_prog_name;
    4747
     48static const char *log_level_names[] = {
     49        "fatal",
     50        "error",
     51        "warn",
     52        "note",
     53        "debug",
     54        "debug2"
     55};
     56
    4857/** IPC session with the logger service. */
    4958static async_sess_t *logger_session;
     
    162171}
    163172
     173const char *log_level_str(log_level_t level)
     174{
     175        if (level >= LVL_LIMIT)
     176                return "unknown";
     177        else
     178                return log_level_names[level];
     179}
     180
    164181/** Initialize the logging system.
    165182 *
  • uspace/lib/c/include/io/log.h

    r04da852 r1c67b41  
    5050} log_level_t;
    5151
     52extern const char *log_level_str(log_level_t);
     53
    5254extern bool __log_shall_record(log_level_t);
    5355extern int log_init(const char *, log_level_t);
  • uspace/srv/logger/namespace.c

    r04da852 r1c67b41  
    218218{
    219219        if (level <= namespace_get_actual_log_level(namespace)) {
    220                 printf("[%s %d]: %s\n", namespace->name, level, message);
    221                 fprintf(namespace->logfile, "[%d]: %s\n", level, message);
     220                const char *level_name = log_level_str(level);
     221                printf("[%s %s]: %s\n", namespace->name, level_name, message);
     222                fprintf(namespace->logfile, "%s: %s\n", level_name, message);
    222223                fflush(namespace->logfile);
    223224                fflush(stdout);
Note: See TracChangeset for help on using the changeset viewer.