Masstronaut / Engine

gonna make it good
3 stars 1 forks source link

Output Message Batching / Buffers #39

Open aaldwell opened 6 years ago

aaldwell commented 6 years ago

Enhancement / Feature. 1 line macro to output text to a buffer of a batching system.

Ideally we would have three separate buffers, 1 for errors, 1 for events, and one for everything else, i.e. general debugging. Separating out message types allows us to more easily filer and navigate the output. The batching system would collect all of these and then output them at the end of the frame to wherever we want, based of those filters. This way, all text output can easily be switched to or additionally output to a log file, or any other source we desire on the file without editing any of the individual lines feeding the buffers.

Potential Examples: //usage ERROR_TEXT("Graphics failed to initialize! value of window handle: ", pWindow); DEBUG_TEXT("Just checking to see if the code hits this line."); EVENT_TEXT("Model loaded: ", m_name);

//directing output TextBatcher.eventBuffer.outputMode = TextBatcher::eOutputModes::Logfile; TextBatcher.errorBuffer.outputMode = TextBatcher::eOutputModes::Screen; TextBatcher.debugBuffer.outputMode = TextBatcher::eOutputModes::Console;

This would replace all std::cout text output currently in the engine and eliminate a building tech debt in this area.

aaldwell commented 6 years ago

Possible implementation details:

  1. put it in Utils, forward declare to_string functions and all types, in some reflection generated file, include in .cpp implementation
  2. template <typename string, typename...> void Log(A...args);
  3. implement for integral types now, but provide way for user-defined types to be added once reflection is in 4, example call: for inline comma style: ERROR_TEXT("Graphics failed to initialize! value of window handle: ", pWindow, "."); //comma delimiter
  4. user must be allowed to provide custom targets such as pWindow