MCPcopy Create free account
hub / github.com/lief-project/LIEF / init_logger

Function init_logger

api/python/src/pyLIEF.cpp:103–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void init_logger(nb::module_& m) {
104 nb::module_ logging = m.def_submodule("logging");
105
106 #define PY_ENUM(x) LIEF::logging::to_string(x), x
107 nb::enum_<logging::LEVEL>(logging, "LEVEL")
108 .value(PY_ENUM(logging::LEVEL::OFF))
109 .value(PY_ENUM(logging::LEVEL::TRACE))
110 .value(PY_ENUM(logging::LEVEL::DEBUG))
111 .value(PY_ENUM(logging::LEVEL::CRITICAL))
112 .value(PY_ENUM(logging::LEVEL::ERR))
113 .value(PY_ENUM(logging::LEVEL::WARN))
114 .value(PY_ENUM(logging::LEVEL::INFO));
115 #undef PY_ENUM
116
117 logging.def("disable", nb::overload_cast<>(&logging::disable),
118 "Disable the logger globally"_doc);
119
120 logging.def("enable", nb::overload_cast<>(&logging::enable),
121 "Enable the logger globally"_doc);
122
123 logging.def("set_level", nb::overload_cast<logging::LEVEL>(&logging::set_level),
124 "Change logging level", "level"_a);
125
126 logging.def("get_level", nb::overload_cast<>(&logging::get_level),
127 "Get current logging level");
128
129 logging.def("set_path", nb::overload_cast<const std::string&>(&logging::set_path),
130 "Change the logger as a file-base logging and set its path"_doc,
131 "path"_a);
132
133 logging.def("log",
134 static_cast<void(*)(LIEF::logging::LEVEL, const std::string&)>(&logging::log),
135 "Log a message with the LIEF's logger"_doc,
136 "level"_a, "msg"_a);
137
138 logging.def("debug",
139 static_cast<void(*)(const std::string&)>(&logging::debug),
140 "Log a :attr:`~.LEVEL.DEBUG` message"_doc, "msg"_a);
141
142 logging.def("info",
143 static_cast<void(*)(const std::string&)>(&logging::info),
144 "Log an :attr:`~.LEVEL.INFO` message"_doc, "msg"_a);
145
146 logging.def("warn",
147 static_cast<void(*)(const std::string&)>(&logging::warn),
148 "Log a :attr:`~.LEVEL.WARN` message"_doc, "msg"_a);
149
150 logging.def("err",
151 static_cast<void(*)(const std::string&)>(&logging::err),
152 "Log an :attr:`~.LEVEL.ERROR` message"_doc, "msg"_a);
153
154 logging.def("critical",
155 static_cast<void(*)(const std::string&)>(&logging::critical),
156 "Log an :attr:`~.LEVEL.CRITICAL` message"_doc, "msg"_a);
157
158 logging.def("enable_debug", nb::overload_cast<>(&logging::enable_debug),
159 "Enable :attr:`~.LEVEL.DEBUG` log level"_doc);
160

Callers 1

initFunction · 0.85

Calls 3

init_python_sinkFunction · 0.85
resetFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected