Documentation for Logger
Former-commit-id: b09dda8a542782667070ea8bf912b552dd6b478a
This commit is contained in:
@@ -15,21 +15,48 @@ namespace Nz
|
||||
StdLogger s_stdLogger;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class Nz::Log
|
||||
* \brief Core class that represents a logger
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Enables the log
|
||||
*
|
||||
* \param enable If true, enables the log
|
||||
*/
|
||||
|
||||
void Log::Enable(bool enable)
|
||||
{
|
||||
s_enabled = enable;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the logger
|
||||
* \return An abstract pointer to the logger
|
||||
*/
|
||||
|
||||
AbstractLogger* Log::GetLogger()
|
||||
{
|
||||
return s_logger;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether or not the logging is enabled
|
||||
* \return true If logging is enabled
|
||||
*/
|
||||
|
||||
bool Log::IsEnabled()
|
||||
{
|
||||
return s_enabled;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the logger
|
||||
*
|
||||
* \param logger AbstractLogger to log
|
||||
*/
|
||||
|
||||
void Log::SetLogger(AbstractLogger* logger)
|
||||
{
|
||||
if (s_logger != &s_stdLogger)
|
||||
@@ -40,28 +67,57 @@ namespace Nz
|
||||
s_logger = &s_stdLogger;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Writes a string in the log
|
||||
*
|
||||
* \param string String to log
|
||||
*
|
||||
* \see WriteError
|
||||
*/
|
||||
|
||||
void Log::Write(const String& string)
|
||||
{
|
||||
if (s_enabled)
|
||||
s_logger->Write(string);
|
||||
|
||||
|
||||
OnLogWrite(string);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Writes the error in the log
|
||||
*
|
||||
* \param type Type of the error
|
||||
* \param error Message of the error
|
||||
* \param line Line of the error
|
||||
* \param file File of the error
|
||||
* \param function Function of the error
|
||||
*
|
||||
* \see Write
|
||||
*/
|
||||
|
||||
void Log::WriteError(ErrorType type, const String& error, unsigned int line, const char* file, const char* function)
|
||||
{
|
||||
if (s_enabled)
|
||||
s_logger->WriteError(type, error, line, file, function);
|
||||
|
||||
|
||||
OnLogWriteError(type, error, line, file, function);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Initializes the Log class
|
||||
* \return true if successful
|
||||
*/
|
||||
|
||||
bool Log::Initialize()
|
||||
{
|
||||
SetLogger(new FileLogger());
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unitializes the Log class
|
||||
*/
|
||||
|
||||
void Log::Uninitialize()
|
||||
{
|
||||
SetLogger(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user