7#ifndef BACKENDS_P4TOOLS_COMMON_LIB_LOGGING_H_
8#define BACKENDS_P4TOOLS_COMMON_LIB_LOGGING_H_
17#include "lib/format.h"
29 friend std::ostream &operator<<(std::ostream &out,
const LogArgument &arg) {
30 return out << arg.value;
35decltype(
auto) logArgument(
const T &arg) {
36 if constexpr (std::is_arithmetic_v<T>) {
39 return LogArgument<T>{arg};
48template <
typename... Arguments>
49void printFeature(
const std::string &label,
int level,
const std::string &fmt,
50 Arguments &&...args) {
52 if (!Log::fileLogLevelIsAtLeast(label.c_str(), level)) {
56 LOG_FEATURE(label.c_str(), level,
57 createFormattedMessage(fmt.c_str(), detail::logArgument(args)...));
62template <
typename... Arguments>
63void printInfo(
const std::string &fmt, Arguments &&...args) {
64 printFeature(
"tools_info", 4, fmt, std::forward<Arguments>(args)...);
70template <
typename... Arguments>
71void printDebug(
const std::string &fmt, Arguments &&...args) {
72 printFeature(
"tools_debug", 4, fmt, std::forward<Arguments>(args)...);