mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine typo in kernel.
This commit is contained in:
parent
735176cab4
commit
35fe05d62c
9 changed files with 1321 additions and 1976 deletions
|
@ -33,15 +33,13 @@
|
|||
|
||||
#include <srs_kernel_consts.hpp>
|
||||
|
||||
/**
|
||||
* the log level, for example:
|
||||
* if specified Debug level, all level messages will be logged.
|
||||
* if specified Warn level, only Warn/Error/Fatal level messages will be logged.
|
||||
*/
|
||||
// The log level, for example:
|
||||
// if specified Debug level, all level messages will be logged.
|
||||
// if specified Warn level, only Warn/Error/Fatal level messages will be logged.
|
||||
enum SrsLogLevel
|
||||
{
|
||||
SrsLogLevelForbidden = 0x00,
|
||||
// only used for very verbose debug, generally,
|
||||
// Only used for very verbose debug, generally,
|
||||
// we compile without this level for high performance.
|
||||
SrsLogLevelVerbose = 0x01,
|
||||
SrsLogLevelInfo = 0x02,
|
||||
|
@ -51,85 +49,63 @@ enum SrsLogLevel
|
|||
SrsLogLevelDisabled = 0x20,
|
||||
};
|
||||
|
||||
/**
|
||||
* the log interface provides method to write log.
|
||||
* but we provides some macro, which enable us to disable the log when compile.
|
||||
* @see also SmtDebug/SmtTrace/SmtWarn/SmtError which is corresponding to Debug/Trace/Warn/Fatal.
|
||||
*/
|
||||
// The log interface provides method to write log.
|
||||
// but we provides some macro, which enable us to disable the log when compile.
|
||||
// @see also SmtDebug/SmtTrace/SmtWarn/SmtError which is corresponding to Debug/Trace/Warn/Fatal.
|
||||
class ISrsLog
|
||||
{
|
||||
public:
|
||||
ISrsLog();
|
||||
virtual ~ISrsLog();
|
||||
public:
|
||||
/**
|
||||
* initialize log utilities.
|
||||
*/
|
||||
// Initialize log utilities.
|
||||
virtual srs_error_t initialize();
|
||||
/**
|
||||
* reopen the log file for log rotate.
|
||||
*/
|
||||
// Reopen the log file for log rotate.
|
||||
virtual void reopen();
|
||||
public:
|
||||
/**
|
||||
* log for verbose, very verbose information.
|
||||
*/
|
||||
// The log for verbose, very verbose information.
|
||||
virtual void verbose(const char* tag, int context_id, const char* fmt, ...);
|
||||
/**
|
||||
* log for debug, detail information.
|
||||
*/
|
||||
// The log for debug, detail information.
|
||||
virtual void info(const char* tag, int context_id, const char* fmt, ...);
|
||||
/**
|
||||
* log for trace, important information.
|
||||
*/
|
||||
// The log for trace, important information.
|
||||
virtual void trace(const char* tag, int context_id, const char* fmt, ...);
|
||||
/**
|
||||
* log for warn, warn is something should take attention, but not a error.
|
||||
*/
|
||||
// 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, ...);
|
||||
/**
|
||||
* log for error, something error occur, do something about the error, ie. close the connection,
|
||||
* but we will donot abort the program.
|
||||
*/
|
||||
// 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, ...);
|
||||
};
|
||||
|
||||
/**
|
||||
* the context id manager to identify context, for instance, the green-thread.
|
||||
* usage:
|
||||
* _srs_context->generate_id(); // when thread start.
|
||||
* _srs_context->get_id(); // get current generated id.
|
||||
* int old_id = _srs_context->set_id(1000); // set context id if need to merge thread context.
|
||||
*/
|
||||
// the context for multiple clients.
|
||||
// The context id manager to identify context, for instance, the green-thread.
|
||||
// Usage:
|
||||
// _srs_context->generate_id(); // when thread start.
|
||||
// _srs_context->get_id(); // get current generated id.
|
||||
// int old_id = _srs_context->set_id(1000); // set context id if need to merge thread context.
|
||||
// The context for multiple clients.
|
||||
class ISrsThreadContext
|
||||
{
|
||||
public:
|
||||
ISrsThreadContext();
|
||||
virtual ~ISrsThreadContext();
|
||||
public:
|
||||
/**
|
||||
* generate the id for current context.
|
||||
*/
|
||||
// Generate the id for current context.
|
||||
virtual int generate_id();
|
||||
/**
|
||||
* get the generated id of current context.
|
||||
*/
|
||||
// Get the generated id of current context.
|
||||
virtual int get_id();
|
||||
/**
|
||||
* set the id of current context.
|
||||
* @return the previous id value; 0 if no context.
|
||||
*/
|
||||
// Set the id of current context.
|
||||
// @return the previous id value; 0 if no context.
|
||||
virtual int set_id(int v);
|
||||
};
|
||||
|
||||
// @global user must provides a log object
|
||||
// @global User must provides a log object
|
||||
extern ISrsLog* _srs_log;
|
||||
|
||||
// @global user must implements the LogContext and define a global instance.
|
||||
// @global User must implements the LogContext and define a global instance.
|
||||
extern ISrsThreadContext* _srs_context;
|
||||
|
||||
// donot print method
|
||||
// Log style.
|
||||
// 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__)
|
||||
|
@ -137,7 +113,6 @@ extern ISrsThreadContext* _srs_context;
|
|||
#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__)
|
||||
#endif
|
||||
// use __FUNCTION__ to print c method
|
||||
#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__)
|
||||
|
@ -145,7 +120,6 @@ extern ISrsThreadContext* _srs_context;
|
|||
#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__)
|
||||
#endif
|
||||
// use __PRETTY_FUNCTION__ to print c++ class:method
|
||||
#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__)
|
||||
|
@ -154,7 +128,7 @@ extern ISrsThreadContext* _srs_context;
|
|||
#define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
// TODO: FIXME: add more verbose and info logs.
|
||||
// TODO: FIXME: Add more verbose and info logs.
|
||||
#ifndef SRS_AUTO_VERBOSE
|
||||
#undef srs_verbose
|
||||
#define srs_verbose(msg, ...) (void)0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue