mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Log: Refine context
This commit is contained in:
parent
0a057a0427
commit
66aaad7805
4 changed files with 32 additions and 5 deletions
|
@ -1699,7 +1699,10 @@ void SrsHttpApi::remark(int64_t* in, int64_t* out)
|
|||
srs_error_t SrsHttpApi::do_cycle()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
||||
// Create context for API.
|
||||
_srs_context->set_id(_srs_context->generate_id());
|
||||
|
||||
srs_trace("API server client, ip=%s:%d", ip.c_str(), port);
|
||||
|
||||
// initialize parser
|
||||
|
|
|
@ -210,8 +210,8 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
|
||||
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
|
||||
remote_sdp_str.length(), local_sdp_str.length());
|
||||
srs_trace("RTC offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC local answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -563,8 +563,8 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
|
||||
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
|
||||
remote_sdp_str.length(), local_sdp_str.length());
|
||||
srs_trace("RTC offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
srs_trace("RTC local answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,16 @@ void SrsThreadContext::clear_cid()
|
|||
}
|
||||
}
|
||||
|
||||
impl_SrsContextRestore::impl_SrsContextRestore(SrsContextId cid)
|
||||
{
|
||||
cid_ = cid;
|
||||
}
|
||||
|
||||
impl_SrsContextRestore::~impl_SrsContextRestore()
|
||||
{
|
||||
_srs_context->set_id(cid_);
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
SrsConsoleLog::SrsConsoleLog(SrsLogLevel l, bool u)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,20 @@ public:
|
|||
virtual void clear_cid();
|
||||
};
|
||||
|
||||
// The context restore stores the context and restore it when done.
|
||||
// Usage:
|
||||
// SrsContextRestore(_srs_context->get_id());
|
||||
#define SrsContextRestore(cid) \
|
||||
impl_SrsContextRestore _context_restore_instance(cid)
|
||||
class impl_SrsContextRestore
|
||||
{
|
||||
private:
|
||||
SrsContextId cid_;
|
||||
public:
|
||||
impl_SrsContextRestore(SrsContextId cid);
|
||||
virtual ~impl_SrsContextRestore();
|
||||
};
|
||||
|
||||
// The basic console log, which write log to console.
|
||||
class SrsConsoleLog : public ISrsLog
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue