-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathlogger.hpp
67 lines (47 loc) · 1.91 KB
/
logger.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <memory>
#include <sstream>
#include <soralog/level.hpp>
#include <soralog/logger.hpp>
#include <soralog/logging_system.hpp>
#include <soralog/macro.hpp>
#include "common/hexutil.hpp"
#include "outcome/outcome.hpp"
// pre-include all formatters
#include "log/formatters/filepath.hpp"
#include "log/formatters/ref_and_ptr.hpp"
#include "log/formatters/tagged.hpp"
#include "log/formatters/variant.hpp"
namespace kagome::log {
using Level = soralog::Level;
struct Logger : std::shared_ptr<soralog::Logger> {
Logger() = delete;
Logger(std::shared_ptr<soralog::Logger> sptr)
: std::shared_ptr<soralog::Logger>(std::move(sptr)) {
BOOST_ASSERT_MSG(get() != nullptr, "Logger does not exist");
};
};
using WLogger = std::weak_ptr<soralog::Logger>;
enum class Error : uint8_t { WRONG_LEVEL = 1, WRONG_GROUP, WRONG_LOGGER };
outcome::result<Level> str2lvl(std::string_view str);
void setLoggingSystem(std::weak_ptr<soralog::LoggingSystem> logging_system);
void tuneLoggingSystem(const std::vector<std::string> &cfg);
void doLogRotate();
static const std::string defaultGroupName("kagome");
[[nodiscard]] Logger createLogger(const std::string &tag);
[[nodiscard]] Logger createLogger(const std::string &tag,
const std::string &group);
[[nodiscard]] Logger createLogger(const std::string &tag,
const std::string &group,
Level level);
bool setLevelOfGroup(const std::string &group_name, Level level);
bool resetLevelOfGroup(const std::string &group_name);
bool setLevelOfLogger(const std::string &logger_name, Level level);
bool resetLevelOfLogger(const std::string &logger_name);
} // namespace kagome::log
OUTCOME_HPP_DECLARE_ERROR(kagome::log, Error);