|
My Project
|
a logger can only write to a given file. More...
#include <Log.h>
Public Member Functions | |
| 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) |
Static Public Member Functions | |
| static CLogger & | GetSingleton () |
| get the default application logger. More... | |
Protected Attributes | |
| std::string | m_log_file_name |
| FILE * | m_file_handle |
| char | m_buffer [MAX_DEBUG_STRING_LENGTH *2+2] |
| mutex | m_mutex |
| bool | m_is_first_time_open |
| bool | m_bForceFlush |
| if true we will flush the new log to file immediately. More... | |
| std::string | m_name |
| The name of this logger. More... | |
| int | m_level |
| The assigned level of this logger. More... | |
a logger can only write to a given file.
Please use LogService to create different loggers. char and wchar_t are supported. Both multi-threaded and single-threaded logging functions are supported. Internally we use a mutex to sync write. Messages are written immediately to file; it uses the system IO cache.
| void ParaEngine::CLogger::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.
| level | the level to log. |
| message | message. |
| location | location of source of logging request. |
| void ParaEngine::CLogger::ForcedLog | ( | const int | level, |
| const std::string & | message | ||
| ) |
This method creates a new logging event and logs the event without further checks.
| level | the level to log. |
| message | message. |
| int ParaEngine::CLogger::GetLevel | ( | ) |
Returns the assigned Level.
| const char * ParaEngine::CLogger::GetLog | ( | int | fromPos, |
| int | nCount | ||
| ) |
get log text between two Log positions.
| fromPos | position in bytes. if nil, it defaults to 0 |
| nCount | count in bytes. if nil, it defaults to end of log file. |
| FILE * ParaEngine::CLogger::GetLogFileHandle | ( | ) |
get the log file handle, and seek to end of file for immediate writing.
| int ParaEngine::CLogger::GetPos | ( | ) |
get the current log file position.
it is equivalent to the log file size in bytes. one can later get log text between two Log positions.
|
static |
get the default application logger.
| bool ParaEngine::CLogger::IsEnabledFor | ( | int | level | ) |
Check whether this logger is enabled for a given Level passed as parameter.
| void ParaEngine::CLogger::log | ( | const int | level, |
| const std::string & | message, | ||
| const ParaEngine::LogDetail::LocationInfo & | location | ||
| ) |
This is the most generic printing method.
It is intended to be invoked by wrapper classes.
| level | The level of the logging request. |
| message | The message of the logging request. |
| location | The source file of the logging request, may be null. |
| void ParaEngine::CLogger::log | ( | const int | level, |
| const std::string & | message | ||
| ) |
This is the most generic printing method.
It is intended to be invoked by wrapper classes.
| level | The level of the logging request. |
| message | The message of the logging request. |
| void ParaEngine::CLogger::SetAppendMode | ( | bool | bAppendToExistingFile | ) |
by default, append mode is enabled in server mode, and disabled in client build.
| void ParaEngine::CLogger::SetForceFlush | ( | bool | bForceFlush | ) |
if true we will flush the new log to file immediately.
otherwise, flush operation is determined by the system. default to true for client log and false for service log.
| void ParaEngine::CLogger::SetLevel | ( | const int | level1 | ) |
set level of this logger.
| void ParaEngine::CLogger::SetLogFile | ( | const std::string & | sFile | ) |
change the log file.
| int ParaEngine::CLogger::Write | ( | const char * | buf, |
| int | nLength | ||
| ) |
write byte array [thread safe]
| buf | buffer pointer |
| nLength | buffer length in bytes. |
| void ParaEngine::CLogger::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.
WriteDebugStr("%s failed in %s() [%d]\n","ErrorXXX", FILE,LINE);
| str | should be a formated string. |
|
protected |
if true we will flush the new log to file immediately.
otherwise, flush operation is determined by the system. default to true for client log and false for service log.
|
protected |
The assigned level of this logger.
Default to 0, the higher, the more important. The level variable need not be assigned a value in which case it is inherited from parent.
|
protected |
The name of this logger.
1.8.12