Compare commits

...
3 Commits
Author SHA256 Message Date
CupWater 7eb3331d8e . 2026-08-17 13:35:14 +08:00
CupWater b4ed8d601d Merge remote-tracking branch 'origin/main'
# Conflicts:
#	include/featherlog/log_formatter.hpp
2026-08-17 13:29:59 +08:00
CupWater e99541c139 . 2026-08-17 11:31:12 +08:00
3 changed files with 29 additions and 36 deletions
+5 -7
View File
@@ -2,16 +2,14 @@
#define FEATHERLOG_LOG_FORMATTER_HPP #define FEATHERLOG_LOG_FORMATTER_HPP
#include <string> #include <string>
#include <featherlog/flog_definitions.h>
#include namespace flog {
class FLOG_API LogFormatter {
namespace flog
{
class LogFormatter
{
public: public:
virtual ~LogFormatter() = default; virtual ~LogFormatter() = default;
virtual std::string format() = 0;
virtual std::string FLOG_CALL format() = 0;
}; };
} }
+4 -5
View File
@@ -3,10 +3,9 @@
#include <cstdint> #include <cstdint>
namespace flog namespace flog {
{ using LogLevelType = uint8_t;
enum class LogLevel : uint8_t enum class LogLevel : LogLevelType {
{
TRACE = 0, TRACE = 0,
DEBUG = 1, DEBUG = 1,
INFO = 2, INFO = 2,
@@ -14,7 +13,7 @@ namespace flog
ERROR = 4, ERROR = 4,
FATAL = 5, FATAL = 5,
OFF = 0xff, OFF = std::numeric_limits<LogLevelType>::max()
}; };
} }
+14 -18
View File
@@ -8,18 +8,14 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "logger.hpp" #include <featherlog/logger.hpp>
#include "log_formatter.hpp" #include <featherlog/log_level.hpp>
#include "log_level.hpp" #include <featherlog/log_message.hpp>
#include "log_message.hpp" #include <featherlog/log_outputter.hpp>
#include "log_outputter.hpp" #include <featherlog/flog_definitions.h>
namespace flog namespace flog {
{ class FLOG_API LogManager : public std::enable_shared_from_this<LogManager> {
class LogManager;
class LogManager : public std::enable_shared_from_this<LogManager>
{
friend class LoggerCallback; friend class LoggerCallback;
public: public:
@@ -28,23 +24,23 @@ namespace flog
LogManager(LogManager &&) = delete; LogManager(LogManager &&) = delete;
LogManager &operator=(LogManager &&) = delete; LogManager &operator=(LogManager &&) = delete;
static std::shared_ptr<LogManager> create(); static std::shared_ptr<LogManager> FLOG_CALL create();
~LogManager(); ~LogManager();
LogLevel get_min_log_level() const noexcept; LogLevel FLOG_CALL get_min_log_level() const noexcept;
void set_min_log_level(LogLevel level) 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: private:
LogManager() noexcept = default; 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}; std::atomic<LogLevel> m_minLogLevel{LogLevel::DEBUG};