正在显示
1 个修改的文件
包含
3 行增加
和
4 行删除
@@ -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; |
-
请 注册 或 登录 后发表评论