libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1
23#ifndef LOGGER_H
24#define LOGGER_H
25
26#include <filesystem>
27#include <memory>
28#include <mutex>
29#include <source_location>
30#include <string>
31#include "loglevel.h"
32
34{
38 class Logger
39 {
40 public:
55 Logger(const std::filesystem::path& path, LogLevel minimum = LogLevel::Debug, bool append = true);
61 const std::filesystem::path& getPath() const;
68 void log(LogLevel level, const std::string& message, const std::source_location& source = std::source_location::current()) const;
69
70 private:
71 mutable std::mutex m_mutex;
72 LogLevel m_minimum;
73 std::filesystem::path m_path;
74 std::shared_ptr<std::ostream> m_stream;
75 };
76}
77
78#endif //LOGGER_H
A logger of application messages.
Definition logger.h:39
Logger(const std::filesystem::path &path, LogLevel minimum=LogLevel::Debug, bool append=true)
Constructs a Logger.
const std::filesystem::path & getPath() const
Gets the path for the logs file.
Logger(LogLevel minimum=LogLevel::Debug)
Constructs a Logger.
void log(LogLevel level, const std::string &message, const std::source_location &source=std::source_location::current()) const
Logs a message.
Definition logger.h:34
LogLevel
Levels of log messages.
Definition loglevel.h:32