Skip to content

Optimize multi-arg logger methods to only call format() if log level allows #2332

@obiltschnig

Description

@obiltschnig

Example:

inline void Logger::debug(const std::string& fmt, const Any& value1)
{
	log(Poco::format(fmt, value1), Message::PRIO_DEBUG);
}

should become:

inline void Logger::debug(const std::string& fmt, const Any& value1)
{
	if (debug())
	{
		logAlways(Poco::format(fmt, value1), Message::PRIO_DEBUG);
	}
}

// ...

inline void Logger::logAlways(const std::string& text, Message::Priority prio, const char* file, int line)
{
	if (_pChannel)
	{
		_pChannel->log(Message(_name, text, prio, file, line));
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions