SHA256
modify something
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#ifndef FEATHERLOG_FEATHERLOG_HPP
|
||||
#define FEATHERLOG_FEATHERLOG_HPP
|
||||
|
||||
#include <featherlog/flog_definitions.h>
|
||||
#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>
|
||||
|
||||
#endif
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <string>
|
||||
#include <featherlog/flog_definitions.h>
|
||||
|
||||
namespace flog {
|
||||
class FLOG_API LogFormatter {
|
||||
namespace flog
|
||||
{
|
||||
class FLOG_API LogFormatter
|
||||
{
|
||||
public:
|
||||
virtual ~LogFormatter() = default;
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace flog {
|
||||
namespace flog
|
||||
{
|
||||
using LogLevelType = uint8_t;
|
||||
enum class LogLevel : LogLevelType {
|
||||
enum class LogLevel : LogLevelType
|
||||
{
|
||||
TRACE = 0,
|
||||
DEBUG = 1,
|
||||
INFO = 2,
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include <featherlog/flog_definitions.h>
|
||||
#include <featherlog/push_result.hpp>
|
||||
|
||||
namespace flog {
|
||||
class FLOG_API LogManager : public std::enable_shared_from_this<LogManager> {
|
||||
friend class LoggerCallback;
|
||||
|
||||
namespace flog
|
||||
{
|
||||
class FLOG_API LogManager : public std::enable_shared_from_this<LogManager>
|
||||
{
|
||||
public:
|
||||
LogManager(const LogManager &) = delete;
|
||||
LogManager &operator=(const LogManager &) = delete;
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
#include <string_view>
|
||||
|
||||
#include <featherlog/log_level.hpp>
|
||||
#include <featherlog/log_message_flag.hpp>
|
||||
|
||||
namespace flog {
|
||||
struct LogMessage {
|
||||
namespace flog
|
||||
{
|
||||
struct LogMessage
|
||||
{
|
||||
std::chrono::system_clock::time_point timestamp;
|
||||
LogLevel level;
|
||||
std::string_view logger_name;
|
||||
std::string text;
|
||||
LogLevel level;
|
||||
MessageFlag flag;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef FEATHERLOG_LOG_MESSAGE_FLAG_HPP
|
||||
#define FEATHERLOG_LOG_MESSAGE_FLAG_HPP
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace flog
|
||||
{
|
||||
typedef uint32_t MessageFlag;
|
||||
|
||||
class MessageFlagManager
|
||||
{
|
||||
public:
|
||||
MessageFlagManager() noexcept = default;
|
||||
~MessageFlagManager() = default;
|
||||
|
||||
MessageFlagManager(const MessageFlagManager&) noexcept = default;
|
||||
MessageFlagManager& operator=(const MessageFlagManager&) noexcept = default;
|
||||
MessageFlagManager(MessageFlagManager&&) noexcept = default;
|
||||
MessageFlagManager& operator=(MessageFlagManager&&) noexcept = default;
|
||||
|
||||
_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
|
||||
|
||||
private:
|
||||
std::array<std::string, std::numeric_limits<MessageFlag>::digits> m_flagMap{};
|
||||
size_t flagCount { 0 };
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,7 @@ namespace flog {
|
||||
virtual void FLOG_CALL write_log(const LogMessage &message) = 0;
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
const std::string m_name;
|
||||
|
||||
std::unique_ptr<LogFormatter> m_logFormatter;
|
||||
};
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
|
||||
#include <featherlog/flog_definitions.h>
|
||||
|
||||
namespace flog {
|
||||
class LoggerManager;
|
||||
namespace flog
|
||||
{
|
||||
class LogManager;
|
||||
|
||||
class FLOG_API Logger {
|
||||
class FLOG_API Logger final
|
||||
{
|
||||
friend class LogManager;
|
||||
|
||||
public:
|
||||
@@ -25,8 +27,8 @@ namespace flog {
|
||||
m_logManager(manager)
|
||||
{ }
|
||||
|
||||
std::string m_name;
|
||||
std::weak_ptr<LogManager> m_logManager;
|
||||
const std::string m_name;
|
||||
const std::weak_ptr<LogManager> m_logManager;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,37 +4,37 @@
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
namespace flog {
|
||||
namespace flog
|
||||
{
|
||||
template <typename T>
|
||||
class PushResult {
|
||||
class PushResult
|
||||
{
|
||||
public:
|
||||
_NODISCARD static PushResult success() noexcept { return PushResult(); }
|
||||
_NODISCARD static PushResult failWithValue(T value) noexcept {
|
||||
_NODISCARD static PushResult failWithValue(T value) noexcept
|
||||
{
|
||||
return PushResult(std::move(std::optional<T>(std::move(value))));
|
||||
}
|
||||
|
||||
_NODISCARD bool isSuccessful() const noexcept { return !m_value.has_value(); }
|
||||
_NODISCARD bool isFail() const noexcept { return m_value.has_value(); }
|
||||
|
||||
void getValueIfFail(const std::function<void(const T& value)> func) const {
|
||||
void getValueIfFail(const std::function<void(const T& value)> func) const
|
||||
{
|
||||
if (isFail()) {
|
||||
func(m_value.value());
|
||||
}
|
||||
}
|
||||
|
||||
_NODISCARD T getValue() const {
|
||||
return m_value.value();
|
||||
}
|
||||
_NODISCARD T getValue() const { return m_value.value(); }
|
||||
|
||||
PushResult(const PushResult &other) noexcept {
|
||||
m_value = other.m_value;
|
||||
}
|
||||
PushResult(const PushResult &other) noexcept { m_value = other.m_value; }
|
||||
|
||||
private:
|
||||
PushResult() noexcept = default;
|
||||
explicit PushResult(std::optional<T> value) noexcept : m_value(std::move(value)) {}
|
||||
|
||||
std::optional<T> m_value = std::nullopt;
|
||||
const std::optional<T> m_value = std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user