Changeset aa389fd in mainline for uspace/lib/usb/src/debug.c
- Timestamp:
- 2011-02-02T12:01:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9f5667a
- Parents:
- 93f8da1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/debug.c
r93f8da1 raa389fd 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.