diff --git a/src/Magnum/DebugOutput.cpp b/src/Magnum/DebugOutput.cpp index d578f5a13..26a80a5b0 100644 --- a/src/Magnum/DebugOutput.cpp +++ b/src/Magnum/DebugOutput.cpp @@ -47,18 +47,59 @@ callbackWrapper(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei #endif void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type type, const UnsignedInt id, const DebugOutput::Severity severity, const std::string& string, const void*) { + Debug output; + output << "Debug output:"; + switch(severity) { case DebugOutput::Severity::High: - Error() << source << type << id << severity << "\n " << string; - break; + output << "high severity"; break; case DebugOutput::Severity::Medium: + output << "medium severity"; break; + case DebugOutput::Severity::Low: - Warning() << source << type << id << severity << "\n " << string; - break; + output << "low severity"; break; + + case DebugOutput::Severity::Notification: ; + } - default: Debug() << source << type << id << severity << "\n " << string; + switch(source) { + case DebugOutput::Source::Api: + output << "API"; break; + case DebugOutput::Source::WindowSystem: + output << "window system"; break; + case DebugOutput::Source::ShaderCompiler: + output << "shader compiler"; break; + case DebugOutput::Source::ThirdParty: + output << "third party"; break; + case DebugOutput::Source::Application: + output << "application"; break; + + case DebugOutput::Source::Other: ; } + + switch(type) { + case DebugOutput::Type::Error: + output << "error"; break; + case DebugOutput::Type::DeprecatedBehavior: + output << "deprecated behavior note"; break; + case DebugOutput::Type::UndefinedBehavior: + output << "undefined behavior note"; break; + case DebugOutput::Type::Portability: + output << "portability note"; break; + case DebugOutput::Type::Performance: + output << "performance note"; break; + case DebugOutput::Type::Marker: + output << "marker"; break; + case DebugOutput::Type::PushGroup: + output << "debug group enter"; break; + case DebugOutput::Type::PopGroup: + output << "debug group leave"; break; + + case DebugOutput::Type::Other: ; + } + + output << '(' + std::to_string(id) + "):" << string; } } diff --git a/src/Magnum/DebugOutput.h b/src/Magnum/DebugOutput.h index ee0f53b0b..4f1a9a711 100644 --- a/src/Magnum/DebugOutput.h +++ b/src/Magnum/DebugOutput.h @@ -95,13 +95,10 @@ DebugOutput::setEnabled(DebugOutput::Source::Api, DebugOutput::Type::Other, {131 With default callback the group entering/leaving and the inserted message (and possibly also other messages) will be printed on standard output: -> DebugOutput::Source::Application DebugOutput::Type::PushGroup 42 DebugOutput::Severity::Notification\n ->     Scene rendering\n -> DebugOutput::Source::Application DebugOutput::Type::Marker 1337 DebugOutput::Severity::Notification\n ->     Rendering transparent mesh\n +> Debug output: application debug group enter (42): Scene rendering\n +> Debug output: application marker (1337): Rendering transparent mesh\n > ...\n -> DebugOutput::Source::Application DebugOutput::Type::PopGroup 42 DebugOutput::Severity::Notification\n ->     Scene rendering +> Debug output: application debug group leave (42): Scene rendering If only @extension2{EXT,debug_marker} or @extension{GREMEDY,string_marker} are supported, only user-inserted messages and debug groups are supported and they @@ -383,15 +380,14 @@ class MAGNUM_EXPORT DebugOutput { * @brief Set default debug message callback * * See @ref setCallback() for more information. The message is printed - * to either @ref Corrade::Utility::Error "Error", @ref Corrade::Utility::Warning "Warning" - * or @ref Corrade::Utility::Debug "Debug" in the following format: + * to @ref Corrade::Utility::Debug "Debug" output in the following + * format: * @code * DebugMessage::insert(DebugMessage::Source::Application, * DebugMessage::Type::Marker, 1337, DebugOutput::Severity::Notification, "Hello from OpenGL command stream!"); * @endcode * - * > DebugOutput::Source::Application DebugOutput::Type::Marker 1337 DebugOutput::Severity::Notification\n - * >     Hello from OpenGL command stream! + * > Debug output: application marker (1337): Hello from OpenGL command stream! */ static void setDefaultCallback(); @@ -437,8 +433,7 @@ DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Mark 1337, DebugOutput::Severity::Notification, "Hello from OpenGL command stream!"); @endcode -> DebugOutput::Source::Application DebugOutput::Type::Marker 1337 DebugOutput::Severity::Notification\n ->     Hello from OpenGL command stream! +> Debug output: application marker (1337): Hello from OpenGL command stream! If only @extension2{EXT,debug_marker} or @extension{GREMEDY,string_marker} are available, the message can be seen only through graphics debugger. @@ -728,10 +723,8 @@ available and the default debug output callback is enabled for these kinds of messages, the group entering and leaving will be printed on standard output in the following form: -> DebugOutput::Source::Application DebugOutput::Type::PushGroup 42 DebugOutput::Severity::Notification\n ->     Scene rendering\n -> DebugOutput::Source::Application DebugOutput::Type::PopGroup 42 DebugOutput::Severity::Notification\n ->     Scene rendering +> Debug output: application debug group enter (42): Scene rendering\n +> Debug output: application debug group leave (42): Scene rendering If only @extension2{EXT,debug_marker} is available, the group can be seen only through graphics debugger. diff --git a/src/Magnum/Test/DebugOutputGLTest.cpp b/src/Magnum/Test/DebugOutputGLTest.cpp index a847d791d..954752a0b 100644 --- a/src/Magnum/Test/DebugOutputGLTest.cpp +++ b/src/Magnum/Test/DebugOutputGLTest.cpp @@ -118,12 +118,11 @@ void DebugOutputGLTest::message() { std::ostringstream out; Debug::setOutput(&out); DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker, - 1337, DebugOutput::Severity::Notification, "Hello from OpenGL command stream!"); + 1337, DebugOutput::Severity::High, "Hello from OpenGL command stream!"); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(out.str(), - "DebugOutput::Source::Application DebugOutput::Type::Marker 1337 DebugOutput::Severity::Notification \n" - " Hello from OpenGL command stream!\n"); + "Debug output: high severity application marker (1337): Hello from OpenGL command stream!\n"); } void DebugOutputGLTest::messageFallback() { @@ -163,20 +162,16 @@ void DebugOutputGLTest::group() { { DebugGroup g1{DebugGroup::Source::Application, 42, "Automatic debug group"}; DebugGroup g2; - g2.push(DebugGroup::Source::Application, 1337, "Manual debug group"); + g2.push(DebugGroup::Source::ThirdParty, 1337, "Manual debug group"); g2.pop(); } MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(out.str(), - "DebugOutput::Source::Application DebugOutput::Type::PushGroup 42 DebugOutput::Severity::Notification \n" - " Automatic debug group\n" - "DebugOutput::Source::Application DebugOutput::Type::PushGroup 1337 DebugOutput::Severity::Notification \n" - " Manual debug group\n" - "DebugOutput::Source::Application DebugOutput::Type::PopGroup 1337 DebugOutput::Severity::Notification \n" - " Manual debug group\n" - "DebugOutput::Source::Application DebugOutput::Type::PopGroup 42 DebugOutput::Severity::Notification \n" - " Automatic debug group\n"); + "Debug output: application debug group enter (42): Automatic debug group\n" + "Debug output: third party debug group enter (1337): Manual debug group\n" + "Debug output: third party debug group leave (1337): Manual debug group\n" + "Debug output: application debug group leave (42): Automatic debug group\n"); } void DebugOutputGLTest::groupFallback() {