LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
logging.hpp
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_LOGGING_H
17#define LIEF_LOGGING_H
18
19#include "LIEF/visibility.h"
20
21#include <string>
22#include <vector>
23
24namespace spdlog {
25class logger;
26}
27
28namespace LIEF {
29namespace logging {
30
36enum class LEVEL {
37 TRACE = 0,
38 DEBUG,
39 INFO,
40 WARN,
41 ERR,
42 CRITICAL,
43};
44
45LIEF_API const char* to_string(LEVEL e);
46
48LIEF_API void disable();
49
51LIEF_API void enable();
52
54LIEF_API void set_level(LEVEL level);
55
57LIEF_API void set_path(const std::string& path);
58
60LIEF_API void log(LEVEL level, const std::string& msg);
61
62LIEF_API void log(LEVEL level, const std::string& fmt,
63 const std::vector<std::string>& args);
64
65template <typename... Args>
66void log(LEVEL level, const std::string& fmt, const Args &... args) {
67 std::vector<std::string> vec_args;
68 vec_args.insert(vec_args.end(), { static_cast<decltype(vec_args)::value_type>(args)...});
69 return log(level, fmt, vec_args);
70}
71
72LIEF_API void set_logger(const spdlog::logger& logger);
73
74LIEF_API void reset();
75
76}
77}
78
79#endif
LIEF namespace.
Definition Abstract/Binary.hpp:31