Changes in uspace/lib/usb/src/debug.c [aa389fd:6028ec8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/debug.c
raa389fd r6028ec8 67 67 /** Serialization mutex for logging functions. */ 68 68 static FIBRIL_MUTEX_INITIALIZE(log_serializer); 69 static FILE *log_stream = NULL;70 69 71 70 /** Find or create new tag with given name. … … 172 171 log_prefix = message_prefix; 173 172 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 }182 173 } 183 174 … … 206 197 void usb_log_printf(usb_log_level_t level, const char *format, ...) 207 198 { 199 if (level > log_level) { 200 return; 201 } 202 208 203 FILE *stream = NULL; 209 204 switch (level) { … … 221 216 va_start(args, format); 222 217 223 /*224 * Serialize access to log files.225 * Always print to log file, to screen print only when the enabled226 * log level is high enough.227 */228 218 fibril_mutex_lock(&log_serializer); 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 219 fprintf(stream, "[%s]%s: ", log_prefix, log_level_name(level)); 220 vfprintf(stream, format, args); 242 221 fibril_mutex_unlock(&log_serializer); 243 222
Note:
See TracChangeset
for help on using the changeset viewer.