The small3d framework
Logger.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
15 #define LOGERROR(MESSAGE) logger->append(loggererror, MESSAGE)
16 
20 #define LOGINFO(MESSAGE) logger->append(loggerinfo, MESSAGE)
21 
25 #if defined(DEBUG) || defined(_DEBUG) || !defined (NDEBUG)
26 #define LOGDEBUG(MESSAGE) logger->append(loggerdebug, MESSAGE)
27 #else
28 #define LOGDEBUG(MESSAGE)
29 #endif
30 
31 #include <ostream>
32 #include <memory>
33 
34 namespace small3d {
35 
39  std::string intToStr(const int number);
40 
44  std::string floatToStr(const float number);
45 
50  enum LogLevel {
51  loggerinfo, loggerdebug, loggererror
52  };
53 
59  class Logger {
60  public:
61 
67  Logger();
68 
73  ~Logger();
74 
82  void append(const LogLevel level, const std::string message) const;
83  };
84 
88  void initLogger();
89 
93  void deleteLogger();
94 }
95 
99 extern std::shared_ptr<small3d::Logger> logger;
The standard logging class for small3d.
Definition: Logger.hpp:59
std::shared_ptr< small3d::Logger > logger
The logger object used by the logging macros.
Definition: Logger.cpp:18
void initLogger()
Initialise the logger.
Definition: Logger.cpp:103
Logger()
Constructor with stream for output.
Definition: Logger.cpp:34
LogLevel
Possible logging levels.
Definition: Logger.hpp:50
void append(const LogLevel level, const std::string message) const
Appends a message to the logger.
Definition: Logger.cpp:42
~Logger()
Destructor.
Definition: Logger.cpp:38
void deleteLogger()
Destroy the logger.
Definition: Logger.cpp:107