Changeset 2159 for pjproject/trunk/pjlib/src/pj/log.c
- Timestamp:
- Jul 19, 2008 5:53:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/log.c
r2039 r2159 32 32 static pj_log_func *log_writer = &pj_log_write; 33 33 static unsigned log_decor = PJ_LOG_HAS_TIME | PJ_LOG_HAS_MICRO_SEC | 34 PJ_LOG_HAS_SENDER | PJ_LOG_HAS_NEWLINE; 34 PJ_LOG_HAS_SENDER | PJ_LOG_HAS_NEWLINE | 35 PJ_LOG_HAS_SPACE 36 #if defined(PJ_WIN32) && PJ_WIN32!=0 37 | PJ_LOG_HAS_COLOR 38 #endif 39 ; 40 41 static pj_color_t PJ_LOG_COLOR_0 = PJ_TERM_COLOR_BRIGHT | PJ_TERM_COLOR_R; 42 static pj_color_t PJ_LOG_COLOR_1 = PJ_TERM_COLOR_BRIGHT | PJ_TERM_COLOR_R; 43 static pj_color_t PJ_LOG_COLOR_2 = PJ_TERM_COLOR_BRIGHT | 44 PJ_TERM_COLOR_R | 45 PJ_TERM_COLOR_G; 46 static pj_color_t PJ_LOG_COLOR_3 = PJ_TERM_COLOR_BRIGHT | 47 PJ_TERM_COLOR_R | 48 PJ_TERM_COLOR_G | 49 PJ_TERM_COLOR_B; 50 static pj_color_t PJ_LOG_COLOR_4 = PJ_TERM_COLOR_R | 51 PJ_TERM_COLOR_G | 52 PJ_TERM_COLOR_B; 53 static pj_color_t PJ_LOG_COLOR_5 = PJ_TERM_COLOR_R | 54 PJ_TERM_COLOR_G | 55 PJ_TERM_COLOR_B; 56 static pj_color_t PJ_LOG_COLOR_6 = PJ_TERM_COLOR_R | 57 PJ_TERM_COLOR_G | 58 PJ_TERM_COLOR_B; 59 /* Default terminal color */ 60 static pj_color_t PJ_LOG_COLOR_77 = PJ_TERM_COLOR_R | 61 PJ_TERM_COLOR_G | 62 PJ_TERM_COLOR_B; 35 63 36 64 #if PJ_LOG_USE_STACK_BUFFER==0 … … 46 74 { 47 75 return log_decor; 76 } 77 78 PJ_DEF(void) pj_log_set_color(int level, pj_color_t color) 79 { 80 switch (level) 81 { 82 case 0: PJ_LOG_COLOR_0 = color; 83 break; 84 case 1: PJ_LOG_COLOR_1 = color; 85 break; 86 case 2: PJ_LOG_COLOR_2 = color; 87 break; 88 case 3: PJ_LOG_COLOR_3 = color; 89 break; 90 case 4: PJ_LOG_COLOR_4 = color; 91 break; 92 case 5: PJ_LOG_COLOR_5 = color; 93 break; 94 case 6: PJ_LOG_COLOR_6 = color; 95 break; 96 /* Default terminal color */ 97 case 77: PJ_LOG_COLOR_77 = color; 98 break; 99 default: 100 /* Do nothing */ 101 break; 102 } 103 } 104 105 PJ_DEF(pj_color_t) pj_log_get_color(int level) 106 { 107 switch (level) { 108 case 0: 109 return PJ_LOG_COLOR_0; 110 case 1: 111 return PJ_LOG_COLOR_1; 112 case 2: 113 return PJ_LOG_COLOR_2; 114 case 3: 115 return PJ_LOG_COLOR_3; 116 case 4: 117 return PJ_LOG_COLOR_4; 118 case 5: 119 return PJ_LOG_COLOR_5; 120 case 6: 121 return PJ_LOG_COLOR_6; 122 default: 123 /* Return default terminal color */ 124 return PJ_LOG_COLOR_77; 125 } 48 126 } 49 127 … … 106 184 } 107 185 if (log_decor & PJ_LOG_HAS_DAY_OF_MON) { 108 *pre++ = ' 186 *pre++ = '-'; 109 187 pre += pj_utoa_pad(ptime.day, pre, 2, '0'); 110 188 } … … 140 218 *pre++ = ' '; 141 219 220 if (log_decor & PJ_LOG_HAS_SPACE) { 221 *pre++ = ' '; 222 } 223 142 224 len = pre - log_buffer; 143 225
Note: See TracChangeset
for help on using the changeset viewer.