Changeset fc51296 in mainline for uspace/lib/c/generic/io/log.c


Ignore:
Timestamp:
2011-03-31T17:37:25Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3acb285
Parents:
9b415c9
Message:

Add logging for device drivers.

File:
1 edited

Legend:

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

    r9b415c9 rfc51296  
    3535#include <errno.h>
    3636#include <fibril_synch.h>
     37#include <stdarg.h>
    3738#include <stdlib.h>
    3839#include <stdio.h>
     
    8990        va_list args;
    9091
     92        va_start(args, fmt);
     93        log_msgv(level, fmt, args);
     94        va_end(args);
     95}
     96
     97/** Write an entry to the log (va_list variant).
     98 *
     99 * @param level         Message verbosity level. Message is only printed
     100 *                      if verbosity is less than or equal to current
     101 *                      reporting level.
     102 * @param fmt           Format string
     103 */
     104void log_msgv(log_level_t level, const char *fmt, va_list args)
     105{
    91106        assert(level < LVL_LIMIT);
    92107
    93108        /* Higher number means higher verbosity. */
    94109        if (level <= log_level) {
    95                 va_start(args, fmt);
    96110                fibril_mutex_lock(&log_serializer);
    97111
    98                 fprintf(log_stream, "%s: %s", log_prog_name,
     112                fprintf(log_stream, "%s: %s: ", log_prog_name,
    99113                    log_level_names[level]);
    100114                vfprintf(log_stream, fmt, args);
     
    102116
    103117                fibril_mutex_unlock(&log_serializer);
    104                 va_end(args);
    105118        }
    106119}
Note: See TracChangeset for help on using the changeset viewer.