Flyby SDK v0.3.0
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <fstream>
11#include <mutex>
12#include <string>
13
14namespace flyby {
19 enum class LogLevel {
20 ERROR = 0,
21 WARNING,
22 INFO,
23 DEBUG,
24 };
25
30 class Logger {
31 public:
37 explicit Logger(const std::string& filepath);
38
39 virtual ~Logger();
40
47
54 virtual void log(LogLevel level, const std::string& message);
55
63 virtual void log(LogLevel level, const std::string& tag, const std::string& message);
64
70 virtual void d(const std::string& message);
71
78 virtual void d(const std::string& tag, const std::string& message);
79
85 virtual void i(const std::string& message);
86
93 virtual void i(const std::string& tag, const std::string& message);
94
100 virtual void w(const std::string& message);
101
108 virtual void w(const std::string& tag, const std::string& message);
109
115 virtual void e(const std::string& message);
116
123 virtual void e(const std::string& tag, const std::string& message);
124
125 protected:
131 Logger() = default;
132
133 private:
134 std::ofstream m_file_stream;
135 std::mutex m_mutex;
136
137 LogLevel m_level;
138 };
139}
The base logger class.
Definition log.h:30
virtual void e(const std::string &tag, const std::string &message)
Logs a message at the error log level.
virtual void log(LogLevel level, const std::string &tag, const std::string &message)
Logs a message at a log level.
virtual void log(LogLevel level, const std::string &message)
Logs a message at a log level.
virtual void w(const std::string &tag, const std::string &message)
Logs a message at the warning log level.
void set_log_level(LogLevel level)
Sets the current log level.
virtual void d(const std::string &tag, const std::string &message)
Logs a message at the debug log level.
Logger(const std::string &filepath)
Constructs a logger that writes to a file.
Logger()=default
Constructs an empty logger.
virtual void i(const std::string &message)
Logs a message at the info log level.
virtual void d(const std::string &message)
Logs a message at the debug log level.
virtual void e(const std::string &message)
Logs a message at the error log level.
virtual void i(const std::string &tag, const std::string &message)
Logs a message at the info log level.
virtual void w(const std::string &message)
Logs a message at the warning log level.
LogLevel
The log level that is displayed with the message in the log.
Definition log.h:19