mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the colorful log for srs. remove the log when client close.
This commit is contained in:
parent
8029b7464a
commit
e5770b10b1
6 changed files with 34 additions and 19 deletions
|
@ -197,7 +197,9 @@ int SrsClient::service_cycle()
|
|||
|
||||
// when not system control error, fatal error, return.
|
||||
if (!srs_is_system_control_error(ret)) {
|
||||
srs_error("stream service cycle failed. ret=%d", ret);
|
||||
if (ret != ERROR_SOCKET_TIMEOUT && !srs_is_client_gracefully_close(ret)) {
|
||||
srs_error("stream service cycle failed. ret=%d", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -409,7 +411,9 @@ int SrsClient::playing(SrsSource* source)
|
|||
|
||||
srs_verbose("play loop recv message. ret=%d", ret);
|
||||
if (ret != ERROR_SUCCESS && ret != ERROR_SOCKET_TIMEOUT) {
|
||||
srs_error("recv client control message failed. ret=%d", ret);
|
||||
if (ret != ERROR_SOCKET_TIMEOUT && !srs_is_client_gracefully_close(ret)) {
|
||||
srs_error("recv client control message failed. ret=%d", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
if ((ret = process_play_control_msg(consumer, msg)) != ERROR_SUCCESS) {
|
||||
|
|
|
@ -63,7 +63,7 @@ void SrsConnection::cycle()
|
|||
ret = do_cycle();
|
||||
|
||||
// if socket io error, set to closed.
|
||||
if (ret == ERROR_SOCKET_READ || ret == ERROR_SOCKET_READ_FULLY || ret == ERROR_SOCKET_WRITE) {
|
||||
if (srs_is_client_gracefully_close(ret)) {
|
||||
ret = ERROR_SOCKET_CLOSED;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ void SrsConnection::cycle()
|
|||
|
||||
// client close peer.
|
||||
if (ret == ERROR_SOCKET_CLOSED) {
|
||||
srs_trace("client disconnect peer. ret=%d", ret);
|
||||
srs_warn("client disconnect peer. ret=%d", ret);
|
||||
}
|
||||
|
||||
server->remove(this);
|
||||
|
|
|
@ -218,11 +218,15 @@ void SrsFastLog::write_log(char *str_log, int size, int _level)
|
|||
log_data[size++] = 0;
|
||||
|
||||
// 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 {
|
||||
// \033[31m : red text code in shell
|
||||
// \033[32m : green text code in shell
|
||||
// \033[33m : yellow text code in shell
|
||||
// \033[0m : normal text code
|
||||
if (_level <= SrsLogLevel::Trace) {
|
||||
printf("%s", str_log);
|
||||
} else if (_level == SrsLogLevel::Warn) {
|
||||
printf("\033[33m%s\033[0m", str_log);
|
||||
} else{
|
||||
printf("\033[31m%s\033[0m", str_log);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue