diff --git a/include/fwk/format.h b/include/fwk/format.h index ba533b2a..8fed1fcc 100644 --- a/include/fwk/format.h +++ b/include/fwk/format.h @@ -338,7 +338,10 @@ template void print(const char *str, T &&...); template void printPlain(const char *str, T &&...); #define FWK_DUMP(...) \ - fwk::print(fwk::detail::autoPrintFormat({FWK_STRINGIZE_MANY(__VA_ARGS__)}).c_str(), __VA_ARGS__) + fwk::print( \ + ("Dump at %:%:\n" + fwk::detail::autoPrintFormat({FWK_STRINGIZE_MANY(__VA_ARGS__)})) \ + .c_str(), \ + __FILE__, __LINE__, __VA_ARGS__) } #endif diff --git a/src/format.cpp b/src/format.cpp index 5b2b2b52..ac102f36 100644 --- a/src/format.cpp +++ b/src/format.cpp @@ -24,6 +24,7 @@ namespace detail { }; bool back_trim = false; + int arg_id = 0; for(auto &arg : args) { if(!arg) break; @@ -36,17 +37,19 @@ namespace detail { DASSERT(elem); back_trim = true; - if(elem[0] == '"' && elem[elem.size() - 1] == '"') { - out << "%"; - back_trim = false; - } else if(anyOf(elem, isspace)) { - out << '"'; - append_elem(elem); - out << "\":% "; - } else { + out << "- arg #" << arg_id; + + bool is_string_literal = elem[0] == '"' && elem[elem.size() - 1] == '"'; + bool is_numeric_value = allOf(elem, [](char c) { return isdigit(c) || c == '.'; }); + bool is_const_value = is_string_literal || is_numeric_value; + + if(!is_const_value) { + out << " ("; append_elem(elem); - out << ":% "; + out << ')'; } + out << ": %\n"; + arg_id++; } if(back_trim)