Skip to content

Poco::Logger can not output __FILE__ and __LINE__ #4553

@siren186

Description

@siren186

Describe the bug
Poco::Logger can not output __FILE__ and __LINE__

To Reproduce

// Here is the problem, It's very strange in my Visual Studio 2019 (with Qt5.15.2)
// I don't know why, The name should be "int", But in fact, name == "long"
std::string name = typeid(__LINE__).name();

poco_information(logger(), "hello"); // Error !!! Log has no __FILE__ and __LINE__
logger().information("hello", __FILE__, __LINE__); // Error !!! Log has no __FILE__ and __LINE__
logger().information("hello", __FILE__, (int)__LINE__); // OK

If the type of __LINE__ is int, Poco::Logger will call this method:

void information(const std::string& msg, const char* file, int line);

But if the type of __LINE__ is long, Poco::Logger will call this method:

template <typename T, typename... Args>
void information(const std::string& fmt, T arg1, Args&&... args)
{
if (information())
	logAlways(Poco::format(fmt, arg1, std::forward<Args>(args)...), Message::PRIO_INFORMATION);
}

Then it will lost __FILE__ and __LINE__.

Please add relevant environment information:

  • Window 10
  • poco-1.13.3
  • Visual Studio 2019

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions