Simple SFML GUI  0.2a
Logger.hpp
1 #ifndef LOGGER_HPP
2 #define LOGGER_HPP
3 
4 #include <SFML/System/String.hpp>
5 #include <vector>
6 #include <fstream>
7 #include <iostream>
8 #include <sstream>
9 #include <chrono>
10 #include <ctime>
11 #include <iomanip>
12 
13 #include "Enums.hpp"
14 
15 class Log {
16 public:
17  std::chrono::system_clock::time_point time;
18  sf::String message;
19  LogLevel level;
20 
21  sf::String parsed;
22 
23  void set(const sf::String& str, LogLevel level);
24  sf::String toString();
25 
26 };
27 
28 class Logger {
29 public:
30  static void close();
31  static bool setFile(const sf::String& path, LogWrite mode = LogWrite::Append);
32  static void write(const sf::String& str, LogLevel level = LogLevel::DebugInfo);
33  static void setLogLevel(LogLevel value);
34  static LogLevel getLogLevel();
35  static sf::String getLastLog();
36  static sf::String getLastError();
37  static std::vector<Log> getFullLog();
38  static void setLogToStdOut(bool value);
39  static void setThrowLevel(LogLevel level);
40 
41 private:
42  Logger() {}
43 
44  static void stdOutWrite();
45  static LogLevel logLevel;
46  static LogLevel throwLevel;
47  static std::wofstream file;
48  static std::vector<Log> fullLog;
49  static bool logToStdOut;
50  static Log log;
51  static bool fileFirstWrite;
52 };
53 
54 #endif // LOGGER_HPP
Definition: Logger.hpp:28
Definition: Logger.hpp:15