diff --git a/libs/kimath/include/math/util.h b/libs/kimath/include/math/util.h index c7329a1faf..32cda82a14 100644 --- a/libs/kimath/include/math/util.h +++ b/libs/kimath/include/math/util.h @@ -31,6 +31,11 @@ #include #include +/** + * Helper to avoid directly including wx/log.h for the templated functions in kimath + */ +void kimathLogDebug( const char* aFormatString, ... ); + /** * Function Clamp * limits @a value within the range @a lower <= @a value <= @a upper. It will work @@ -70,6 +75,8 @@ constexpr ret_type KiROUND( fp_type v ) if( std::numeric_limits::max() < ret || std::numeric_limits::lowest() > ret ) { + kimathLogDebug( "Overflow KiROUND converting value %f to %s", double( v ), + typeid( ret_type ).name() ); return 0; } diff --git a/libs/kimath/src/math/util.cpp b/libs/kimath/src/math/util.cpp index dd74dc4d43..4998bc0fea 100644 --- a/libs/kimath/src/math/util.cpp +++ b/libs/kimath/src/math/util.cpp @@ -27,6 +27,21 @@ #include #include #include +#include + +void kimathLogDebug( const char* aFormatString, ... ) +{ + if( wxLog::IsLevelEnabled( wxLOG_Debug, wxASCII_STR( wxLOG_COMPONENT ) ) ) + { + va_list argList; + va_start( argList, aFormatString ); + + wxVLogWarning( aFormatString, argList ); + + va_end( argList ); + } +} + template<> int rescale( int aNumerator, int aValue, int aDenominator )