39 throw std::runtime_error(
"A filename must be specified for the Logger.ToFile logger type. Please use Logger::Logger(const std::string&) constructor instead.");
43 std::ostringstream msg;
44 msg <<
"The logger type '" << loggerType <<
"' is not recognized. Cannot construct a Logger.";
45 throw std::runtime_error(msg.str().c_str());
Declaration of the Logger class used in the Bridge Pattern.
static std::unique_ptr< ILogger > CreateLogger()
Create an instance of a console logger, which writes to the standard output.
static std::unique_ptr< ILogger > CreateLogger(const std::string &filename)
Create an instance of a file logger, which writes to a file.
void LogInfo(std::string message)
Log informational messages to the configured output.
void LogTrace(std::string message)
LoggerTypes
A value passed to Logger.Logger() constructor to specify the type of logger to create.
@ ToFile
Log to a file. One additional parameter: the name of the file to log to.
@ ToNull
Log to nowhere, that is, throw out all logging. No additional parameters.
@ ToConsole
Log to the console. No additional parameters.
void LogError(std::string message)
Log error messages to the configured output.
std::unique_ptr< ILogger > _logger
Logger(LoggerTypes loggerType)
Constructor that takes a LoggerTypes value to create a new Logger class.
static std::unique_ptr< ILogger > CreateLogger()
Create an instance of a null logger, a logger that doesn't do anything.
Declaration of the ConsoleLogger class used in the Bridge Pattern.
Declaration of the FileLogger class used in the Bridge Pattern.
Declaration of the NullLogger class used in the Bridge Pattern.
The namespace containing all Design Pattern Examples implemented in C++.