Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-03-18 11:00:00 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8029b7464abf7897cb73636a9ed2c72b584fe575
8029b746
2 parents
618f6f52
109ce07c
Merge pull request #28 from wenjiegit/master
merge from wenjie.zhao for colorful log.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
19 行增加
和
9 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_log.cpp
trunk/src/app/srs_app_log.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
8029b74
...
...
@@ -308,7 +308,7 @@ int SrsConfDirective::read_token(SrsFileBuffer* buffer, std::vector<string>& arg
srs_error
(
"line %d: unexpected end of file, expecting ; or
\"
}
\"
"
,
buffer
->
line
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
}
srs_error
(
"end of file. ret=%d"
,
ret
);
srs_trace
(
"end of file. ret=%d"
,
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_log.cpp
查看文件 @
8029b74
...
...
@@ -81,7 +81,7 @@ void SrsFastLog::verbose(const char* tag, int context_id, const char* fmt, ...)
size
+=
vsnprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
fmt
,
ap
);
va_end
(
ap
);
write_log
(
log_data
,
size
);
write_log
(
log_data
,
size
,
SrsLogLevel
::
Verbose
);
}
void
SrsFastLog
::
info
(
const
char
*
tag
,
int
context_id
,
const
char
*
fmt
,
...)
...
...
@@ -101,7 +101,7 @@ void SrsFastLog::info(const char* tag, int context_id, const char* fmt, ...)
size
+=
vsnprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
fmt
,
ap
);
va_end
(
ap
);
write_log
(
log_data
,
size
);
write_log
(
log_data
,
size
,
SrsLogLevel
::
Info
);
}
void
SrsFastLog
::
trace
(
const
char
*
tag
,
int
context_id
,
const
char
*
fmt
,
...)
...
...
@@ -121,7 +121,7 @@ void SrsFastLog::trace(const char* tag, int context_id, const char* fmt, ...)
size
+=
vsnprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
fmt
,
ap
);
va_end
(
ap
);
write_log
(
log_data
,
size
);
write_log
(
log_data
,
size
,
SrsLogLevel
::
Trace
);
}
void
SrsFastLog
::
warn
(
const
char
*
tag
,
int
context_id
,
const
char
*
fmt
,
...)
...
...
@@ -141,7 +141,7 @@ void SrsFastLog::warn(const char* tag, int context_id, const char* fmt, ...)
size
+=
vsnprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
fmt
,
ap
);
va_end
(
ap
);
write_log
(
log_data
,
size
);
write_log
(
log_data
,
size
,
SrsLogLevel
::
Warn
);
}
void
SrsFastLog
::
error
(
const
char
*
tag
,
int
context_id
,
const
char
*
fmt
,
...)
...
...
@@ -161,7 +161,10 @@ void SrsFastLog::error(const char* tag, int context_id, const char* fmt, ...)
size
+=
vsnprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
fmt
,
ap
);
va_end
(
ap
);
write_log
(
log_data
,
size
);
// add strerror() to error msg.
size
+=
snprintf
(
log_data
+
size
,
LOG_MAX_SIZE
-
size
,
"(%s)"
,
strerror
(
errno
));
write_log
(
log_data
,
size
,
SrsLogLevel
::
Error
);
}
bool
SrsFastLog
::
generate_header
(
const
char
*
tag
,
int
context_id
,
const
char
*
level_name
,
int
*
header_size
)
...
...
@@ -203,7 +206,7 @@ bool SrsFastLog::generate_header(const char* tag, int context_id, const char* le
return
true
;
}
void
SrsFastLog
::
write_log
(
char
*
str_log
,
int
size
)
void
SrsFastLog
::
write_log
(
char
*
str_log
,
int
size
,
int
_level
)
{
// ensure the tail and EOF of string
// LOG_TAIL_SIZE for the TAIL char.
...
...
@@ -214,5 +217,12 @@ void SrsFastLog::write_log(char* str_log, int size)
log_data
[
size
++
]
=
LOG_TAIL
;
log_data
[
size
++
]
=
0
;
printf
(
"%s"
,
str_log
);
// if is error msg, then print color msg.
// \033[1;31m : red text code in shell
// \033[1;31m : normal text code
if
(
_level
==
SrsLogLevel
::
Error
)
{
printf
(
"
\033
[1;31m%s
\033
[0m"
,
str_log
);
}
else
{
printf
(
"%s"
,
str_log
);
}
}
...
...
trunk/src/app/srs_app_log.hpp
查看文件 @
8029b74
...
...
@@ -91,7 +91,7 @@ public:
virtual
void
error
(
const
char
*
tag
,
int
context_id
,
const
char
*
fmt
,
...);
private
:
virtual
bool
generate_header
(
const
char
*
tag
,
int
context_id
,
const
char
*
level_name
,
int
*
header_size
);
virtual
void
write_log
(
char
*
str_log
,
int
size
);
virtual
void
write_log
(
char
*
str_log
,
int
size
,
int
_level
);
};
#endif
...
...
请
注册
或
登录
后发表评论