|
| CServiceLogger (const char *filename=NULL, bool bAppendMode=true) |
|
void | WriteServiceFormated (const char *,...) |
| it will write an ordinary formated message to service log with current date time prepended. More...
|
|
void | AddLogStr (const char *pStr) |
| [thread safe]
|
|
void | AddLogStr (const wchar_t *pStr) |
|
void | AddLogStr_st (const char *pStr) |
| single threaded version
|
|
void | AddLogStr_st (const wchar_t *pStr) |
|
void | SetLogFile (const std::string &sFile) |
| change the log file. More...
|
|
const std::string & | GetLogFile () |
|
void | WriteFormated (const char *,...) |
| output to log file a formatted string [thread safe]
|
|
void | WriteFormatedVarList (const char *, va_list args) |
|
void | WriteFormated (const wchar_t *,...) |
|
void | WriteFormated_WithTime (const char *,...) |
|
void | WriteFormated_st (const char *,...) |
| single threaded version
|
|
void | WriteFormated_st (const wchar_t *,...) |
|
int | Write (const char *buf, int nLength) |
| write byte array [thread safe] More...
|
|
int | Write_st (const char *buf, int nLength) |
| single threaded version
|
|
int | GetPos () |
| get the current log file position. More...
|
|
const char * | GetLog (int fromPos, int nCount) |
| get log text between two Log positions. More...
|
|
void | CloseLog () |
| close the log file handle
|
|
FILE * | GetLogFileHandle () |
| get the log file handle, and seek to end of file for immediate writing. More...
|
|
void | WriteDebugStr (const char *zFormat, const char *str, const char *sFile, int nLine) |
| output a string to log file with a given file name and line number in a given format,when compiled in debug mode e.g. More...
|
|
const std::string & | GetName () |
| Get the logger name.
|
|
void | SetAppendMode (bool bAppendToExistingFile) |
| by default, append mode is enabled in server mode, and disabled in client build. More...
|
|
void | SetForceFlush (bool bForceFlush) |
| if true we will flush the new log to file immediately. More...
|
|
int | GetLevel () |
| Returns the assigned Level. More...
|
|
void | SetLevel (const int level1) |
| set level of this logger. More...
|
|
bool | IsEnabledFor (int level) |
| Check whether this logger is enabled for a given Level passed as parameter. More...
|
|
void | log (const int level, const std::string &message, const ParaEngine::LogDetail::LocationInfo &location) |
| This is the most generic printing method. More...
|
|
void | log (const int level, const char *message, const ParaEngine::LogDetail::LocationInfo &location) |
|
void | log (const int level, const std::string &message) |
| This is the most generic printing method. More...
|
|
void | log (const int level, const char *message) |
|
void | ForcedLog (const int level, const std::string &message, const ParaEngine::LogDetail::LocationInfo &location) |
| This method creates a new logging event and logs the event without further checks. More...
|
|
void | ForcedLog (const int level, const char *message, const ParaEngine::LogDetail::LocationInfo &location) |
|
void | ForcedLog (const int level, const std::string &message) |
| This method creates a new logging event and logs the event without further checks. More...
|
|
void | ForcedLog (const int level, const char *message) |
|
CServiceLogger is a more advanced multi-threaded logger than the simple CLogger it supports log level, formatting, log time output, etc.
Please use CLogService to create an instance of CServiceLogger
- Note
- : All server daemon can GetLogger on startup (only once), keep the CServiceLogger_ptr and use it for logging thereafterwards. Example: keep the g_router_logger, and use it for logging, do not call GetLogger again. CServiceLogger_ptr g_router_logger = CLogService::GetLogger("router"); create an unnamed logger. CServiceLogger_ptr logger(new CServiceLogger("mylog.txt", false));
SERVICE_LOG(g_router_logger, 0, "some message1 here"); SERVICE_LOG(g_router_logger, 0, "some message2 here");
Another note: service log do not provide formatted string like application log. Such design is deliberate because snprintf is a slow function and should be used sparingly on server side. If you do need to use formated string, use
SERVICE_LOG1(g_router_logger, "Hello");
SERVICE_LOG1(g_router_logger, "Hello %s", "ParaEngine");