Design Pattern Examples
Overview of object-oriented design patterns
Bridge_Logger.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __BRIDGE_LOGGER_H__
8#define __BRIDGE_LOGGER_H__
9
10#include <memory>
11#include <string>
13
15{
16
22 class Logger
23 {
24 private:
25 // The logger implementation represented by the ILogger interface.
26 std::unique_ptr<ILogger> _logger;
27
28 public:
34 {
39
44
49 };
50
51 public:
58 Logger(LoggerTypes loggerType);
59
64 Logger(const std::string& filename);
65
69 void LogTrace(std::string message);
70
75 void LogInfo(std::string message);
76
81 void LogError(std::string message);
82
83 };
84
85} // end namespace
86
87#endif // __BRIDGE_LOGGER_H__
88
LoggerTypes
A value passed to CreateLogger() to specify the type of logger to create.
Declaration of the ILogger interface used by all logger classes in the Bridge Pattern.
Represents the logger object to be used in the program.
Definition: Bridge_Logger.h:23
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.
Definition: Bridge_Logger.h:34
@ ToFile
Log to a file. One additional parameter: the name of the file to log to.
Definition: Bridge_Logger.h:43
@ ToNull
Log to nowhere, that is, throw out all logging. No additional parameters.
Definition: Bridge_Logger.h:38
@ ToConsole
Log to the console. No additional parameters.
Definition: Bridge_Logger.h:48
void LogError(std::string message)
Log error messages to the configured output.
std::unique_ptr< ILogger > _logger
Definition: Bridge_Logger.h:26
The namespace containing all Design Pattern Examples implemented in C++.