mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	Revamp of terminal color codes
The core module related to coloring terminal output was old and needed some love. The main thing here was an attempt to get rid of the obscene number of stack-local buffers that were allocated for no other reason than to colorize some output. Instead, this uses a simple trick to allocate several buffers within threadlocal storage, then automatically rotates between them, so that you can make multiple calls to the colorization routine within one function and not need to allocate multiple buffers. Review: https://reviewboard.asterisk.org/r/2241/ Patches: bug.patch uploaded by Tilghman Lesher git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381448 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -1082,7 +1082,6 @@ static void logger_print_normal(struct logmsg *logmsg) | ||||
| 			/* Console channels */ | ||||
| 			} else if (chan->type == LOGTYPE_CONSOLE && (chan->logmask & (1 << logmsg->level))) { | ||||
| 				char linestr[128]; | ||||
| 				char tmp1[80], tmp2[80], tmp3[80], tmp4[80]; | ||||
|  | ||||
| 				/* If the level is verbose, then skip it */ | ||||
| 				if (logmsg->level == __LOG_VERBOSE) | ||||
| @@ -1091,14 +1090,14 @@ static void logger_print_normal(struct logmsg *logmsg) | ||||
| 				/* Turn the numerical line number into a string */ | ||||
| 				snprintf(linestr, sizeof(linestr), "%d", logmsg->line); | ||||
| 				/* Build string to print out */ | ||||
| 				snprintf(buf, sizeof(buf), "[%s] %s[%d]%s: %s:%s %s: %s", | ||||
| 				snprintf(buf, sizeof(buf), "[%s] " COLORIZE_FMT "[%d]%s: " COLORIZE_FMT ":" COLORIZE_FMT " " COLORIZE_FMT ": %s", | ||||
| 					 logmsg->date, | ||||
| 					 term_color(tmp1, logmsg->level_name, colors[logmsg->level], 0, sizeof(tmp1)), | ||||
| 					 COLORIZE(colors[logmsg->level], 0, logmsg->level_name), | ||||
| 					 logmsg->lwp, | ||||
| 					 call_identifier_str, | ||||
| 					 term_color(tmp2, logmsg->file, COLOR_BRWHITE, 0, sizeof(tmp2)), | ||||
| 					 term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), | ||||
| 					 term_color(tmp4, logmsg->function, COLOR_BRWHITE, 0, sizeof(tmp4)), | ||||
| 					 COLORIZE(COLOR_BRWHITE, 0, logmsg->file), | ||||
| 					 COLORIZE(COLOR_BRWHITE, 0, linestr), | ||||
| 					 COLORIZE(COLOR_BRWHITE, 0, logmsg->function), | ||||
| 					 logmsg->message); | ||||
| 				/* Print out */ | ||||
| 				ast_console_puts_mutable(buf, logmsg->level); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user