mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Log: Change cid from int to string
This commit is contained in:
parent
bca4ec1da1
commit
8a0c2e01f8
42 changed files with 301 additions and 307 deletions
|
@ -411,7 +411,7 @@ private:
|
|||
std::string file;
|
||||
int line;
|
||||
|
||||
int cid;
|
||||
std::string cid;
|
||||
int rerrno;
|
||||
|
||||
std::string desc;
|
||||
|
|
|
@ -42,23 +42,23 @@ void ISrsLog::reopen()
|
|||
{
|
||||
}
|
||||
|
||||
void ISrsLog::verbose(const char* /*tag*/, int /*context_id*/, const char* /*fmt*/, ...)
|
||||
void ISrsLog::verbose(const char* /*tag*/, const char* /*context_id*/, const char* /*fmt*/, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void ISrsLog::info(const char* /*tag*/, int /*context_id*/, const char* /*fmt*/, ...)
|
||||
void ISrsLog::info(const char* /*tag*/, const char* /*context_id*/, const char* /*fmt*/, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void ISrsLog::trace(const char* /*tag*/, int /*context_id*/, const char* /*fmt*/, ...)
|
||||
void ISrsLog::trace(const char* /*tag*/, const char* /*context_id*/, const char* /*fmt*/, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void ISrsLog::warn(const char* /*tag*/, int /*context_id*/, const char* /*fmt*/, ...)
|
||||
void ISrsLog::warn(const char* /*tag*/, const char* /*context_id*/, const char* /*fmt*/, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void ISrsLog::error(const char* /*tag*/, int /*context_id*/, const char* /*fmt*/, ...)
|
||||
void ISrsLog::error(const char* /*tag*/, const char* /*context_id*/, const char* /*fmt*/, ...)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -70,19 +70,19 @@ ISrsThreadContext::~ISrsThreadContext()
|
|||
{
|
||||
}
|
||||
|
||||
int ISrsThreadContext::generate_id()
|
||||
std::string ISrsThreadContext::generate_id()
|
||||
{
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
int ISrsThreadContext::get_id()
|
||||
std::string ISrsThreadContext::get_id()
|
||||
{
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
int ISrsThreadContext::set_id(int /*v*/)
|
||||
std::string ISrsThreadContext::set_id(std::string /*v*/)
|
||||
{
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <srs_kernel_consts.hpp>
|
||||
|
||||
|
@ -64,16 +65,16 @@ public:
|
|||
virtual void reopen();
|
||||
public:
|
||||
// The log for verbose, very verbose information.
|
||||
virtual void verbose(const char* tag, int context_id, const char* fmt, ...);
|
||||
virtual void verbose(const char* tag, const char* context_id, const char* fmt, ...);
|
||||
// The log for debug, detail information.
|
||||
virtual void info(const char* tag, int context_id, const char* fmt, ...);
|
||||
virtual void info(const char* tag, const char* context_id, const char* fmt, ...);
|
||||
// The log for trace, important information.
|
||||
virtual void trace(const char* tag, int context_id, const char* fmt, ...);
|
||||
virtual void trace(const char* tag, const char* context_id, const char* fmt, ...);
|
||||
// The log for warn, warn is something should take attention, but not a error.
|
||||
virtual void warn(const char* tag, int context_id, const char* fmt, ...);
|
||||
virtual void warn(const char* tag, const char* context_id, const char* fmt, ...);
|
||||
// The log for error, something error occur, do something about the error, ie. close the connection,
|
||||
// but we will donot abort the program.
|
||||
virtual void error(const char* tag, int context_id, const char* fmt, ...);
|
||||
virtual void error(const char* tag, const char* context_id, const char* fmt, ...);
|
||||
};
|
||||
|
||||
// The context id manager to identify context, for instance, the green-thread.
|
||||
|
@ -89,12 +90,12 @@ public:
|
|||
virtual ~ISrsThreadContext();
|
||||
public:
|
||||
// Generate the id for current context.
|
||||
virtual int generate_id();
|
||||
virtual std::string generate_id();
|
||||
// Get the generated id of current context.
|
||||
virtual int get_id();
|
||||
virtual std::string get_id();
|
||||
// Set the id of current context.
|
||||
// @return the previous id value; 0 if no context.
|
||||
virtual int set_id(int v);
|
||||
virtual std::string set_id(std::string v);
|
||||
};
|
||||
|
||||
// @global User must provides a log object
|
||||
|
@ -107,25 +108,25 @@ extern ISrsThreadContext* _srs_context;
|
|||
// Use __FUNCTION__ to print c method
|
||||
// Use __PRETTY_FUNCTION__ to print c++ class:method
|
||||
#if 1
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(NULL, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(NULL, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(NULL, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(NULL, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(NULL, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(NULL, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(NULL, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(NULL, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(NULL, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(NULL, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
#if 0
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(__FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(__FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(__FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(__FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(__FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(__FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(__FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(__FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(__FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(__FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
#if 0
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#define srs_verbose(msg, ...) _srs_log->verbose(__PRETTY_FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_info(msg, ...) _srs_log->info(__PRETTY_FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_trace(msg, ...) _srs_log->trace(__PRETTY_FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_warn(msg, ...) _srs_log->warn(__PRETTY_FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id().c_str(), msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
// TODO: FIXME: Add more verbose and info logs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue