This commit is contained in:
CupWater
2026-08-17 13:35:14 +08:00
parent b4ed8d601d
commit 7eb3331d8e
3 changed files with 24 additions and 27 deletions
+6 -6
View File
@@ -2,15 +2,15 @@
#define FEATHERLOG_LOG_FORMATTER_HPP
#include <string>
#include <featherlog/flog_definitions.h>
namespace flog
{
class FLOG_API LogFormatter
{
namespace flog {
class FLOG_API LogFormatter {
public:
virtual ~LogFormatter() = default;
virtual FLOG_CALL std::string format() = 0;
virtual std::string FLOG_CALL format() = 0;
};
}
#endif
#endif
+5 -6
View File
@@ -3,10 +3,9 @@
#include <cstdint>
namespace flog
{
enum class LogLevel : uint8_t
{
namespace flog {
using LogLevelType = uint8_t;
enum class LogLevel : LogLevelType {
TRACE = 0,
DEBUG = 1,
INFO = 2,
@@ -14,8 +13,8 @@ namespace flog
ERROR = 4,
FATAL = 5,
OFF = 0xff,
OFF = std::numeric_limits<LogLevelType>::max()
};
}
#endif
#endif
+13 -15
View File
@@ -14,35 +14,33 @@
#include <featherlog/log_outputter.hpp>
#include <featherlog/flog_definitions.h>
namespace flog
{
class FLOG_API LogManager : public std::enable_shared_from_this<LogManager>
{
namespace flog {
class FLOG_API LogManager : public std::enable_shared_from_this<LogManager> {
friend class LoggerCallback;
public:
LogManager(const LogManager&) = delete;
LogManager& operator=(const LogManager&) = delete;
LogManager(LogManager&&) = delete;
LogManager& operator=(LogManager&&) = delete;
LogManager(const LogManager &) = delete;
LogManager &operator=(const LogManager &) = delete;
LogManager(LogManager &&) = delete;
LogManager &operator=(LogManager &&) = delete;
static std::shared_ptr<LogManager> create();
static std::shared_ptr<LogManager> FLOG_CALL create();
~LogManager();
LogLevel get_min_log_level() const noexcept;
void set_min_log_level(LogLevel level) noexcept;
LogLevel FLOG_CALL get_min_log_level() const noexcept;
void FLOG_CALL set_min_log_level(LogLevel level) noexcept;
void add_outputter(std::unique_ptr<LogOutputter> outputter);
void FLOG_CALL add_outputter(std::unique_ptr<LogOutputter> outputter);
std::shared_ptr<Logger> get_logger(const std::string& name);
std::shared_ptr<Logger> FLOG_CALL get_logger(const std::string &name);
size_t clean_unused_loggers();
size_t FLOG_CALL clean_unused_loggers();
private:
LogManager() noexcept = default;
void print_log(const LogMessage& message) const;
void FLOG_CALL print_log(const LogMessage &message) const;
std::atomic<LogLevel> m_minLogLevel{LogLevel::DEBUG};