tufang14

Update srs_app_log.cpp

issue#207
@@ -326,7 +326,6 @@ void SrsFastLog::write_log(int& fd, char *str_log, int size, int level) @@ -326,7 +326,6 @@ void SrsFastLog::write_log(int& fd, char *str_log, int size, int level)
326 326
327 // add some to the end of char. 327 // add some to the end of char.
328 str_log[size++] = LOG_TAIL; 328 str_log[size++] = LOG_TAIL;
329 - str_log[size++] = 0;  
330 329
331 // if not to file, to console and return. 330 // if not to file, to console and return.
332 if (!log_to_file_tank) { 331 if (!log_to_file_tank) {
@@ -336,11 +335,11 @@ void SrsFastLog::write_log(int& fd, char *str_log, int size, int level) @@ -336,11 +335,11 @@ void SrsFastLog::write_log(int& fd, char *str_log, int size, int level)
336 // \033[33m : yellow text code in shell 335 // \033[33m : yellow text code in shell
337 // \033[0m : normal text code 336 // \033[0m : normal text code
338 if (level <= SrsLogLevel::Trace) { 337 if (level <= SrsLogLevel::Trace) {
339 - printf("%s", str_log); 338 + printf("%.*s", size, str_log);
340 } else if (level == SrsLogLevel::Warn) { 339 } else if (level == SrsLogLevel::Warn) {
341 - printf("\033[33m%s\033[0m", str_log); 340 + printf("\033[33m%.*s\033[0m", size, str_log);
342 } else{ 341 } else{
343 - printf("\033[31m%s\033[0m", str_log); 342 + printf("\033[31m%.*s\033[0m", size, str_log);
344 } 343 }
345 344
346 return; 345 return;