Changeset 2159 for pjproject/trunk/pjlib/src/pj/log_writer_stdout.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_writer_stdout.c
r2039 r2159 21 21 #include <pj/compat/stdfileio.h> 22 22 23 #define CLR_FATAL (PJ_TERM_COLOR_BRIGHT | PJ_TERM_COLOR_R)24 #define CLR_WARNING (PJ_TERM_COLOR_BRIGHT | PJ_TERM_COLOR_R | PJ_TERM_COLOR_G)25 #define CLR_INFO (PJ_TERM_COLOR_BRIGHT | PJ_TERM_COLOR_R | PJ_TERM_COLOR_G | \26 PJ_TERM_COLOR_B)27 #define CLR_DEFAULT (PJ_TERM_COLOR_R | PJ_TERM_COLOR_G | PJ_TERM_COLOR_B)28 23 29 24 static void term_set_color(int level) 30 25 { 31 26 #if defined(PJ_TERM_HAS_COLOR) && PJ_TERM_HAS_COLOR != 0 32 unsigned attr = 0; 33 switch (level) { 34 case 0: 35 case 1: attr = CLR_FATAL; 36 break; 37 case 2: attr = CLR_WARNING; 38 break; 39 case 3: attr = CLR_INFO; 40 break; 41 default: 42 attr = CLR_DEFAULT; 43 break; 44 } 45 46 pj_term_set_color(attr); 27 pj_term_set_color(pj_log_get_color(level)); 47 28 #endif 48 29 } … … 51 32 { 52 33 #if defined(PJ_TERM_HAS_COLOR) && PJ_TERM_HAS_COLOR != 0 53 pj_term_set_color(CLR_DEFAULT); 34 /* Set terminal to its default color */ 35 pj_term_set_color(pj_log_get_color(77)); 54 36 #endif 55 37 } … … 62 44 63 45 /* Copy to terminal/file. */ 64 term_set_color(level); 65 printf("%s", buffer); 66 term_restore_color(); 46 if (pj_log_get_decor() & PJ_LOG_HAS_COLOR) { 47 term_set_color(level); 48 printf("%s", buffer); 49 term_restore_color(); 50 } else { 51 printf("%s", buffer); 52 } 67 53 } 68 54
Note: See TracChangeset
for help on using the changeset viewer.