Changes in / [3597dab:a887bd1] in mainline
- Location:
- uspace/lib/usb/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/addrkeep.c
r3597dab ra887bd1 149 149 &addresses->default_condvar_guard); 150 150 } 151 addresses->default_available = false; 151 152 fibril_mutex_unlock(&addresses->default_condvar_guard); 152 153 } -
uspace/lib/usb/src/debug.c
r3597dab ra887bd1 67 67 /** Serialization mutex for logging functions. */ 68 68 static FIBRIL_MUTEX_INITIALIZE(log_serializer); 69 static FILE *log_stream = NULL; 69 70 70 71 /** Find or create new tag with given name. … … 171 172 log_prefix = message_prefix; 172 173 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 } 173 182 } 174 183 … … 197 206 void usb_log_printf(usb_log_level_t level, const char *format, ...) 198 207 { 199 if (level > log_level) {200 return;201 }202 203 208 FILE *stream = NULL; 204 209 switch (level) { … … 216 221 va_start(args, format); 217 222 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 */ 218 228 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 221 242 fibril_mutex_unlock(&log_serializer); 222 243
Note:
See TracChangeset
for help on using the changeset viewer.