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:
|
2013-04-14 22:24:31 +03:00
|
|
|
CBasicLogConfigurator(const std::string & filePath, CConsoleHandler * 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-05 13:29:46 +03:00
|
|
|
|
2013-04-09 17:31:36 +03:00
|
|
|
private:
|
2013-04-14 22:24:31 +03:00
|
|
|
ELogLevel::ELogLevel getLogLevel(const std::string & level) const;
|
|
|
|
EConsoleTextColor::EConsoleTextColor getConsoleColor(const std::string & colorName) const;
|
2013-04-09 17:31:36 +03:00
|
|
|
|
2013-04-14 22:24:31 +03:00
|
|
|
std::string filePath;
|
|
|
|
CConsoleHandler * console;
|
|
|
|
bool appendToLogFile;
|
2013-04-05 13:29:46 +03:00
|
|
|
};
|