Skip to content

Stream Logging #915

@hdino

Description

@hdino

Feature request

Feature description

Stream logging should be implemented as it

  1. has better type handling (type safety and no need to change a format string if the type changes)
  2. allows simple output of types not supported by the printf format specifiers.

Implementation considerations

The stream log commands could use the existing log functions. Simplified example:

#include <sstream>

#define LOG(...) printf(__VA_ARGS__)
#define LOG_STREAM(args) std::stringstream ss; ss << args; LOG("%s", ss.str().c_str())

int main()
{
    int a = 2019;
    std::string s = "World";
    
    LOG("Hello %s %i\n", s.c_str(), a);
    LOG_STREAM("Hello " << s << " " << a << "\n");
    
    return 0;
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions