Changeset 698
- Timestamp:
- 11/04/07 03:19:01 (16 years ago)
- Files:
-
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (11 diffs)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/debugmodule/debugmodule.cpp
r693 r698 84 84 ... ) const 85 85 { 86 87 // bypass for performance 88 #ifdef IMPLEMENT_BACKLOG 89 if (level > BACKLOG_MIN_LEVEL 90 && level > m_level) { 91 return; 92 } 93 #else 94 if ( level >m_level ) { 95 return; 96 } 97 #endif 98 86 99 const char *warning = "WARNING: message truncated!\n"; 87 100 const int warning_size = 32; … … 105 118 } 106 119 120 #ifdef IMPLEMENT_BACKLOG 107 121 // print to backlog if necessary 108 122 if (level <= BACKLOG_MIN_LEVEL) { 109 123 DebugModuleManager::instance()->backlog_print( msg ); 110 124 } 125 #endif 111 126 112 127 // print to stderr if necessary … … 124 139 ... ) const 125 140 { 141 // bypass for performance 142 #ifdef IMPLEMENT_BACKLOG 143 if (level > BACKLOG_MIN_LEVEL 144 && level > m_level) { 145 return; 146 } 147 #else 148 if ( level >m_level ) { 149 return; 150 } 151 #endif 152 126 153 const char *warning = "WARNING: message truncated!\n"; 127 154 const int warning_size = 32; … … 170 197 } 171 198 199 #ifdef IMPLEMENT_BACKLOG 172 200 // print to backlog if necessary 173 201 if (level <= BACKLOG_MIN_LEVEL) { 174 202 DebugModuleManager::instance()->backlog_print( msg ); 175 203 } 204 #endif 176 205 177 206 // print to stderr if necessary … … 208 237 , mb_outbuffer(0) 209 238 , mb_overruns(0) 239 #ifdef IMPLEMENT_BACKLOG 210 240 , bl_mb_inbuffer(0) 241 #endif 211 242 { 212 243 … … 245 276 pthread_cond_destroy(&mb_ready_cond); 246 277 278 #ifdef IMPLEMENT_BACKLOG 279 pthread_mutex_destroy(&bl_mb_write_lock); 280 #endif 281 247 282 } 248 283 … … 263 298 mb_initialized = 1; 264 299 300 #ifdef IMPLEMENT_BACKLOG 265 301 pthread_mutex_init(&bl_mb_write_lock, NULL); 302 #endif 266 303 267 304 if (pthread_create(&mb_writer_thread, NULL, &mb_thread_func, (void *)this) != 0) … … 377 414 } 378 415 416 #ifdef IMPLEMENT_BACKLOG 379 417 void 380 418 DebugModuleManager::showBackLog() … … 400 438 } 401 439 440 void 441 DebugModuleManager::showBackLog(int nblines) 442 { 443 DebugModuleManager *m=DebugModuleManager::instance(); 444 // locking the flush lock ensures that the backlog is 445 // printed as one entity 446 pthread_mutex_lock(&m->mb_flush_lock); 447 fprintf(stderr, "=====================================================\n"); 448 fprintf(stderr, "* BEGIN OF BACKLOG PRINT\n"); 449 fprintf(stderr, "=====================================================\n"); 450 451 int lines_to_skip = BACKLOG_MB_BUFFERS - nblines; 452 if (lines_to_skip < 0) lines_to_skip = 0; 453 for (unsigned int i=0; i<BACKLOG_MB_BUFFERS;i++) { 454 if (lines_to_skip-- < 0) { 455 unsigned int idx=(i+bl_mb_inbuffer)%BACKLOG_MB_BUFFERS; 456 fputs(bl_mb_buffers[idx], stderr); 457 } 458 } 459 fprintf(stderr, "\n"); 460 461 fprintf(stderr, "=====================================================\n"); 462 fprintf(stderr, "* END OF BACKLOG PRINT\n"); 463 fprintf(stderr, "=====================================================\n"); 464 pthread_mutex_unlock(&m->mb_flush_lock); 465 } 466 #endif 467 402 468 void * 403 469 DebugModuleManager::mb_thread_func(void *arg) … … 424 490 } 425 491 492 #ifdef IMPLEMENT_BACKLOG 426 493 void 427 494 DebugModuleManager::backlog_print(const char *msg) … … 444 511 // just bail out should it have failed 445 512 } 513 #endif 446 514 447 515 void trunk/libffado/src/debugmodule/debugmodule.h
r693 r698 52 52 #define MB_BUFFERSIZE DEBUG_MAX_MESSAGE_LENGTH 53 53 54 // #define IMPLEMENT_BACKLOG 55 #ifdef IMPLEMENT_BACKLOG 54 56 // the backlog is a similar buffer as the message buffer 55 57 #define BACKLOG_MB_BUFFERS (256) 56 58 #define BACKLOG_MB_NEXT(index) (((index)+1) & (BACKLOG_MB_BUFFERS-1)) 57 #define BACKLOG_MIN_LEVEL DEBUG_LEVEL_VER Y_VERBOSE58 59 #define BACKLOG_MIN_LEVEL DEBUG_LEVEL_VERBOSE 60 #endif 59 61 60 62 #define debugFatal( format, args... ) \ … … 119 121 120 122 #define flushDebugOutput() DebugModuleManager::instance()->flush() 121 #define debugShowBackLog() DebugModuleManager::instance()->showBackLog() 123 124 #ifdef IMPLEMENT_BACKLOG 125 126 #define debugShowBackLog() DebugModuleManager::instance()->showBackLog() 127 #define debugShowBackLogLines(x) DebugModuleManager::instance()->showBackLog(x) 128 129 #else 130 #define debugShowBackLog() 131 #define debugShowBackLogLines(x) 132 133 #endif 122 134 123 135 #ifdef DEBUG … … 229 241 // much output in normal operation 230 242 void showBackLog(); 243 void showBackLog(int nblines); 231 244 232 245 protected: … … 258 271 void mb_flush(); 259 272 273 #ifdef IMPLEMENT_BACKLOG 260 274 // the backlog 261 275 char bl_mb_buffers[BACKLOG_MB_BUFFERS][MB_BUFFERSIZE]; 262 276 unsigned int bl_mb_inbuffer; 263 277 pthread_mutex_t bl_mb_write_lock; 278 #endif 264 279 265 280 static DebugModuleManager* m_instance;