1#ifndef BACKENDS_P4TOOLS_COMMON_LIB_LOGGING_H_
2#define BACKENDS_P4TOOLS_COMMON_LIB_LOGGING_H_
9#include <boost/format.hpp>
16inline std::string
logHelper(boost::format &f) {
return f.str(); }
19template <
class T,
class... Args>
20std::string
logHelper(boost::format &f, T &&t, Args &&...args) {
21 return logHelper(f % std::forward<T>(t), std::forward<Args>(args)...);
27template <
typename... Arguments>
28void printFeature(
const std::string &label,
int level,
const std::string &fmt,
29 Arguments &&...args) {
31 if (!Log::fileLogLevelIsAtLeast(label.c_str(), level)) {
36 LOG_FEATURE(label.c_str(), level,
logHelper(f, std::forward<Arguments>(args)...));
41template <
typename... Arguments>
42void printInfo(
const std::string &fmt, Arguments &&...args) {
43 printFeature(
"tools_info", 4, fmt, std::forward<Arguments>(args)...);
49template <
typename... Arguments>
50void printDebug(
const std::string &fmt, Arguments &&...args) {
51 printFeature(
"tools_debug", 4, fmt, std::forward<Arguments>(args)...);