LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
logging.hpp
Go to the documentation of this file.
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,
43};
44
45LIEF_API const char* to_string(LEVEL e);
46
49
52
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
75
76}
77}
78
79#endif
void set_path(const std::string &path)
Change the logger as a file-base logging and set its path.
void enable()
Globally enable the logging module.
void disable()
Globally disable the logging module.
LEVEL
Hierarchical logging level
Definition logging.hpp:36
void log(LEVEL level, const std::string &msg)
Log a message with the LIEF's logger.
void set_level(LEVEL level)
Change the logging level (hierarchical)
void set_logger(const spdlog::logger &logger)
const char * to_string(LEVEL e)
LIEF namespace.
Definition Abstract/Binary.hpp:32
Definition logging.hpp:24
#define LIEF_API
Definition visibility.h:41