Changeset a887bd1 in mainline


Ignore:
Timestamp:
2011-02-04T12:12:47Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ff244e6
Parents:
3597dab (diff), 9f5667a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge: minor fixes and improvements

Location:
uspace/lib/usb/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/addrkeep.c

    r3597dab ra887bd1  
    149149                        &addresses->default_condvar_guard);
    150150        }
     151        addresses->default_available = false;
    151152        fibril_mutex_unlock(&addresses->default_condvar_guard);
    152153}
  • uspace/lib/usb/src/debug.c

    r3597dab ra887bd1  
    6767/** Serialization mutex for logging functions. */
    6868static FIBRIL_MUTEX_INITIALIZE(log_serializer);
     69static FILE *log_stream = NULL;
    6970
    7071/** Find or create new tag with given name.
     
    171172        log_prefix = message_prefix;
    172173        log_level = level;
     174        if (log_stream == NULL) {
     175                char *fname;
     176                int rc = asprintf(&fname, "/log/%s", message_prefix);
     177                if (rc > 0) {
     178                        log_stream = fopen(fname, "w");
     179                        free(fname);
     180                }
     181        }
    173182}
    174183
     
    197206void usb_log_printf(usb_log_level_t level, const char *format, ...)
    198207{
    199         if (level > log_level) {
    200                 return;
    201         }
    202 
    203208        FILE *stream = NULL;
    204209        switch (level) {
     
    216221        va_start(args, format);
    217222
     223        /*
     224         * Serialize access to log files.
     225         * Always print to log file, to screen print only when the enabled
     226         * log level is high enough.
     227         */
    218228        fibril_mutex_lock(&log_serializer);
    219         fprintf(stream, "[%s]%s: ", log_prefix, log_level_name(level));
    220         vfprintf(stream, format, args);
     229
     230        const char *level_name = log_level_name(level);
     231
     232        if (log_stream != NULL) {
     233                fprintf(log_stream, "[%s]%s: ", log_prefix, level_name);
     234                vfprintf(log_stream, format, args);
     235        }
     236
     237        if (level <= log_level) {
     238                fprintf(stream, "[%s]%s: ", log_prefix, level_name);
     239                vfprintf(stream, format, args);
     240        }
     241
    221242        fibril_mutex_unlock(&log_serializer);
    222243
Note: See TracChangeset for help on using the changeset viewer.