Reputation: 1049
I'm using POCO (v 1.4.6p4) logging framework but I have some problem on formatting strings:
int MyClass::MyMethod(unsigned short number) {
Logger::get("MyLog").information(Poco::format("Log a number [%u]", number));
}
Here I get:
Log a number [ERRFMT]
And a Poco::BadCastException is thrown.
Digging into the source I noted that the exception is thrown into the Any class:
template <typename ValueType>
ValueType AnyCast(const Any& operand)
/// AnyCast operator used to extract a copy of the ValueType from an const Any&.
///
/// Example Usage:
/// MyType tmp = AnyCast<MyType>(anAny).
/// Will throw a BadCastException if the cast fails.
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
/// these cases.
{
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
if (!result) throw BadCastException("Failed to convert between const Any types");
return *result;
}
Could someone tell me where I wrong?
Upvotes: 2
Views: 4488