SHA256
modify something
This commit is contained in:
+8
-1
@@ -4,6 +4,10 @@ project(FeatherLog)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
add_compile_definitions(FLOG_IMPL_CONSOLE_OUTPUTTER) # build with default console outputter
|
||||
add_compile_definitions(FLOG_IMPL_FILE_OUTPUTTER) # build with default file outputter
|
||||
add_compile_definitions(FLOG_IMPL_DEFAULT_FORMATTER) # build with default formatter
|
||||
|
||||
# 定义源文件
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
include/featherlog/log_manager.hpp
|
||||
@@ -16,7 +20,10 @@ set(${PROJECT_NAME}_SOURCES
|
||||
include/featherlog/push_result.hpp
|
||||
include/featherlog/log_message_flag.hpp
|
||||
include/featherlog/featherlog.hpp
|
||||
src/log_manager.cpp)
|
||||
src/log_manager.cpp
|
||||
src/log_message_flag.cpp
|
||||
include/featherlog/impl/flog_impl.hpp
|
||||
include/featherlog/impl/console_outputter.hpp)
|
||||
|
||||
# 生成静态库
|
||||
add_library(${PROJECT_NAME}_static STATIC ${${PROJECT_NAME}_SOURCES})
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
#define FEATHERLOG_FEATHERLOG_HPP
|
||||
|
||||
#include <featherlog/flog_definitions.h>
|
||||
#include <featherlog/logger.hpp>
|
||||
#include <featherlog/log_formatter.hpp>
|
||||
#include <featherlog/log_level.hpp>
|
||||
#include <featherlog/log_manager.hpp>
|
||||
#include <featherlog/log_message.hpp>
|
||||
#include <featherlog/log_message_flag.hpp>
|
||||
#include <featherlog/log_outputter.hpp>
|
||||
#include <featherlog/logger.hpp>
|
||||
#include <featherlog/push_result.hpp>
|
||||
|
||||
#include <featherlog/impl/flog_impl.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,4 +27,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _NODISCARD
|
||||
#define _NODISCARD [[nodiscard]]
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef FLOG_IMPL_CONSOLE_OUTPUTTER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef FEATHERLOG_IMPL_FLOG_IMPL_HPP
|
||||
#define FEATHERLOG_IMPL_FLOG_IMPL_HPP
|
||||
|
||||
#include <featherlog/impl/console_outputter.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOG_FORMATTER_HPP
|
||||
#define FEATHERLOG_LOG_FORMATTER_HPP
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <featherlog/flog_definitions.h>
|
||||
@@ -11,8 +10,6 @@ namespace flog
|
||||
public:
|
||||
virtual ~LogFormatter() = default;
|
||||
|
||||
virtual std::string FLOG_CALL format() = 0;
|
||||
_NODISCARD virtual std::string FLOG_CALL format(const LogMessage& message) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOG_LEVEL_HPP
|
||||
#define FEATHERLOG_LOG_LEVEL_HPP
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -18,5 +17,3 @@ namespace flog
|
||||
OFF = std::numeric_limits<LogLevelType>::max()
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOG_MANAGER_HPP
|
||||
#define FEATHERLOG_LOG_MANAGER_HPP
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
@@ -28,14 +27,16 @@ namespace flog
|
||||
|
||||
~LogManager();
|
||||
|
||||
LogLevel FLOG_CALL get_min_log_level() const noexcept;
|
||||
_NODISCARD LogLevel FLOG_CALL get_min_log_level() const noexcept;
|
||||
void FLOG_CALL set_min_log_level(LogLevel level) noexcept;
|
||||
|
||||
PushResult<std::unique_ptr<LogOutputter>> FLOG_CALL add_outputter(std::unique_ptr<LogOutputter> outputter);
|
||||
bool FLOG_CALL contains_outputter(std::string_view name) const noexcept;
|
||||
std::optional<std::unique_ptr<LogOutputter>> FLOG_CALL try_delete_outputter(std::string_view name) noexcept;
|
||||
_NODISCARD PushResult<std::unique_ptr<LogOutputter>> FLOG_CALL add_outputter(
|
||||
std::unique_ptr<LogOutputter> outputter);
|
||||
|
||||
std::shared_ptr<Logger> FLOG_CALL get_logger(const std::string &name);
|
||||
_NODISCARD bool FLOG_CALL contains_outputter(std::string_view name) const;
|
||||
std::optional<std::unique_ptr<LogOutputter>> FLOG_CALL try_delete_outputter(std::string_view name);
|
||||
|
||||
_NODISCARD std::shared_ptr<Logger> FLOG_CALL get_logger(const std::string &name);
|
||||
|
||||
size_t FLOG_CALL clean_unused_loggers();
|
||||
|
||||
@@ -53,5 +54,3 @@ namespace flog
|
||||
std::unordered_map<std::string, std::shared_ptr<Logger>> m_loggers;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOG_MESSAGE_HPP
|
||||
#define FEATHERLOG_LOG_MESSAGE_HPP
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string_view>
|
||||
@@ -19,5 +17,3 @@ namespace flog
|
||||
MessageFlag flag;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef FEATHERLOG_LOG_MESSAGE_FLAG_HPP
|
||||
#define FEATHERLOG_LOG_MESSAGE_FLAG_HPP
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <limits>
|
||||
|
||||
namespace flog
|
||||
{
|
||||
@@ -21,12 +21,11 @@ namespace flog
|
||||
_NODISCARD bool isFull() const noexcept { return flagCount >= std::numeric_limits<MessageFlag>::digits; }
|
||||
_NODISCARD bool pushable() const noexcept { return !isFull(); }
|
||||
_NODISCARD bool isEmpty() const noexcept { return flagCount == 0; }
|
||||
// _NODISCARD
|
||||
|
||||
_NODISCARD bool contains(std::string_view name) const noexcept;
|
||||
|
||||
private:
|
||||
std::array<std::string, std::numeric_limits<MessageFlag>::digits> m_flagMap{};
|
||||
size_t flagCount { 0 };
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOG_OUTPUTTER_HPP
|
||||
#define FEATHERLOG_LOG_OUTPUTTER_HPP
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -11,7 +10,8 @@ namespace flog {
|
||||
class FLOG_API LogOutputter {
|
||||
public:
|
||||
explicit LogOutputter(std::string name, std::unique_ptr<LogFormatter> formatter) noexcept
|
||||
: m_name(std::move(name)), m_logFormatter(std::move(formatter)) {}
|
||||
: m_name(std::move(name)), m_logFormatter(std::move(formatter))
|
||||
{ }
|
||||
|
||||
virtual ~LogOutputter() = default;
|
||||
|
||||
@@ -28,5 +28,3 @@ namespace flog {
|
||||
std::unique_ptr<LogFormatter> m_logFormatter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_LOGGER_HPP
|
||||
#define FEATHERLOG_LOGGER_HPP
|
||||
#pragma once
|
||||
|
||||
#include <format>
|
||||
#include <source_location>
|
||||
@@ -31,5 +30,3 @@ namespace flog
|
||||
const std::weak_ptr<LogManager> m_logManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef FEATHERLOG_PUSH_RESULT_HPP
|
||||
#define FEATHERLOG_PUSH_RESULT_HPP
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
@@ -37,5 +36,3 @@ namespace flog
|
||||
const std::optional<T> m_value = std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -43,13 +43,13 @@ namespace flog
|
||||
return PushResult<std::unique_ptr<LogOutputter>>::success();
|
||||
}
|
||||
|
||||
bool LogManager::contains_outputter(const std::string_view name) const noexcept
|
||||
bool LogManager::contains_outputter(const std::string_view name) const
|
||||
{
|
||||
std::shared_lock lock(m_logOutputtersMutex);
|
||||
return m_logOutputters.contains(name.data());
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<LogOutputter>> LogManager::try_delete_outputter(const std::string_view name) noexcept
|
||||
std::optional<std::unique_ptr<LogOutputter>> LogManager::try_delete_outputter(const std::string_view name)
|
||||
{
|
||||
if (contains_outputter(name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user