正在显示
2 个修改的文件
包含
18 行增加
和
2 行删除
| @@ -105,7 +105,7 @@ int SrsClient::get_peer_ip() | @@ -105,7 +105,7 @@ int SrsClient::get_peer_ip() | ||
| 105 | ip = new char[strlen(buf) + 1]; | 105 | ip = new char[strlen(buf) + 1]; |
| 106 | strcpy(ip, buf); | 106 | strcpy(ip, buf); |
| 107 | 107 | ||
| 108 | - srs_info("get peer ip success. ip=%s, fd=%d", ip, fd); | 108 | + srs_trace("get peer ip success. ip=%s, fd=%d", ip, fd); |
| 109 | 109 | ||
| 110 | return ret; | 110 | return ret; |
| 111 | } | 111 | } |
| @@ -51,18 +51,34 @@ public: | @@ -51,18 +51,34 @@ public: | ||
| 51 | // user must implements the LogContext and define a global instance. | 51 | // user must implements the LogContext and define a global instance. |
| 52 | extern ILogContext* log_context; | 52 | extern ILogContext* log_context; |
| 53 | 53 | ||
| 54 | +// donot print method | ||
| 54 | #if 0 | 55 | #if 0 |
| 55 | #define srs_verbose(msg, ...) printf("[%s][%d][verbs] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") | 56 | #define srs_verbose(msg, ...) printf("[%s][%d][verbs] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") |
| 56 | #define srs_info(msg, ...) printf("[%s][%d][infos] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") | 57 | #define srs_info(msg, ...) printf("[%s][%d][infos] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") |
| 57 | #define srs_trace(msg, ...) printf("[%s][%d][trace] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") | 58 | #define srs_trace(msg, ...) printf("[%s][%d][trace] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf("\n") |
| 58 | #define srs_warn(msg, ...) printf("[%s][%d][warns] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | 59 | #define srs_warn(msg, ...) printf("[%s][%d][warns] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") |
| 59 | #define srs_error(msg, ...) printf("[%s][%d][error] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | 60 | #define srs_error(msg, ...) printf("[%s][%d][error] ", log_context->format_time(), log_context->get_id());printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") |
| 60 | -#else | 61 | +// use __FUNCTION__ to print c method |
| 62 | +#elif 1 | ||
| 61 | #define srs_verbose(msg, ...) printf("[%s][%d][verbs][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | 63 | #define srs_verbose(msg, ...) printf("[%s][%d][verbs][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") |
| 62 | #define srs_info(msg, ...) printf("[%s][%d][infos][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | 64 | #define srs_info(msg, ...) printf("[%s][%d][infos][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") |
| 63 | #define srs_trace(msg, ...) printf("[%s][%d][trace][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | 65 | #define srs_trace(msg, ...) printf("[%s][%d][trace][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") |
| 64 | #define srs_warn(msg, ...) printf("[%s][%d][warns][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | 66 | #define srs_warn(msg, ...) printf("[%s][%d][warns][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") |
| 65 | #define srs_error(msg, ...) printf("[%s][%d][error][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | 67 | #define srs_error(msg, ...) printf("[%s][%d][error][%s] ", log_context->format_time(), log_context->get_id(), __FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") |
| 68 | +// use __PRETTY_FUNCTION__ to print c++ class:method | ||
| 69 | +#else | ||
| 70 | + #define srs_verbose(msg, ...) printf("[%s][%d][verbs][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 71 | + #define srs_info(msg, ...) printf("[%s][%d][infos][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 72 | + #define srs_trace(msg, ...) printf("[%s][%d][trace][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 73 | + #define srs_warn(msg, ...) printf("[%s][%d][warns][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | ||
| 74 | + #define srs_error(msg, ...) printf("[%s][%d][error][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n") | ||
| 75 | +#endif | ||
| 76 | + | ||
| 77 | +#if 0 | ||
| 78 | + #undef srs_verbose | ||
| 79 | + #define srs_verbose(msg, ...) (void)0 | ||
| 80 | + #undef srs_info | ||
| 81 | + #define srs_info(msg, ...) (void)0 | ||
| 66 | #endif | 82 | #endif |
| 67 | 83 | ||
| 68 | #endif | 84 | #endif |
-
请 注册 或 登录 后发表评论