2013-04-05 13:29:46 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CBasicLogConfigurator.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-04-11 18:58:01 +03:00
|
|
|
#include "../CConsoleHandler.h"
|
2013-04-05 13:29:46 +03:00
|
|
|
|
|
|
|
class CConsoleHandler;
|
2013-04-09 17:31:36 +03:00
|
|
|
class JsonNode;
|
2013-04-05 13:29:46 +03:00
|
|
|
|
2013-04-09 17:31:36 +03:00
|
|
|
/// The class CBasicLogConfigurator reads log properties from settings.json and
|
2013-04-10 20:18:01 +03:00
|
|
|
/// sets up the logging system. Make sure that you use the same configurator object to
|
|
|
|
/// initialize the whole logging system. If you don't do so, the log file will be overwritten/truncated.
|
2013-04-05 13:29:46 +03:00
|
|
|
class DLL_LINKAGE CBasicLogConfigurator
|
|
|
|
{
|
|
|
|
public:
|
2014-08-21 23:26:28 +03:00
|
|
|
CBasicLogConfigurator(boost::filesystem::path filePath, CConsoleHandler * const console);
|
2013-04-05 13:29:46 +03:00
|
|
|
|
2013-04-14 22:24:31 +03:00
|
|
|
/// Configures the logging system by parsing the logging settings. It adds the console target and the file target to the global logger.
|
|
|
|
/// Doesn't throw, but logs on success or fault.
|
|
|
|
void configure();
|
2013-04-09 17:31:36 +03:00
|
|
|
|
2013-04-14 22:24:31 +03:00
|
|
|
/// Configures a default logging system by adding the console target and the file target to the global logger.
|
|
|
|
void configureDefault();
|
2013-04-09 17:31:36 +03:00
|
|
|
private:
|
2014-08-11 00:42:39 +03:00
|
|
|
// Gets ELogLevel enum from string. (Should be moved to CLogger as a separate function?)
|
|
|
|
// Throws: std::runtime_error
|
|
|
|
static ELogLevel::ELogLevel getLogLevel(const std::string & level);
|
|
|
|
// Gets EConsoleTextColor enum from strings. (Should be moved to CLogger as a separate function?)
|
|
|
|
// Throws: std::runtime_error
|
|
|
|
static EConsoleTextColor::EConsoleTextColor getConsoleColor(const std::string & colorName);
|
|
|
|
|
2014-08-11 22:24:31 +03:00
|
|
|
boost::filesystem::path filePath;
|
2013-04-14 22:24:31 +03:00
|
|
|
CConsoleHandler * console;
|
|
|
|
bool appendToLogFile;
|
2013-04-05 13:29:46 +03:00
|
|
|
};
|