mason/src/loggger.h

37 lines
712 B
C
Raw Normal View History

2023-09-01 21:39:24 +00:00
#pragma once
#include <list>
#include <string>
#include <mutex>
#include <array>
#include <string_view>
#include <iostream>
class Logger {
public:
enum class Severity {
debug,
info,
minor,
major,
warning,
error,
fatal
};
typedef std::pair<Severity, std::string> Message;
Logger(Severity severity = Severity::info);
~Logger();
void log (Severity severity, const std::string& comment) const;
std::list<Message> getLog() const;
void printLog(bool colored = true);
private:
const Severity currentSeverity;
mutable std::list<Message> history;
mutable std::mutex readMutex;
mutable std::mutex writeMutex;
};