Ignore:
Timestamp:
05/21/18 14:01:14 (6 years ago)
Author:
Maciej Komosinski
Message:

Improved shortening of long stringified values in error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.h

    r784 r786  
    252252};
    253253
     254template<typename T> struct quote_in_messages { constexpr static const char* value = "'"; };
     255template<> struct quote_in_messages < SString > { constexpr static const char* value = "\""; };
     256template<typename T> struct length_in_messages { static const bool value = false; };
     257template<> struct length_in_messages < SString > { static const bool value = true; };
     258
    254259class SimpleAbstractParam : public virtual ParamInterface
    255260{
     
    298303                        SString actual = get(i);
    299304                        bool s_type = type(i)[0] == 's';
    300                         logPrintf("Param", "set", LOG_WARN, "Setting '%s.%s = %s' exceeded allowed range (too %s). %s to %s.",
    301                                 getName(), id(i), sstringShorten(svaluetoset, 30).c_str(), (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", sstringShorten(actual, 30).c_str());
     305                        logPrintf("Param", "set", LOG_WARN, "Setting %s.%s = %s exceeded allowed range (too %s). %s to %s.",
     306                                getName(), id(i),
     307                                ::sstringDelimitAndShorten(svaluetoset, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str(),
     308                                (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted",
     309                                ::sstringDelimitAndShorten(actual, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str()
     310                                );
    302311                }
    303312        }
Note: See TracChangeset for help on using the changeset viewer.