1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Log: Refine context

This commit is contained in:
winlin 2020-07-13 13:52:23 +08:00
parent 0a057a0427
commit 66aaad7805
4 changed files with 32 additions and 5 deletions

View file

@ -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)
{

View file

@ -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
{