How do we handle console output?
Windows uses the wrong encoding for glib output: https://gitlab.com/inkscape/inkscape/commit/408cb49b5559a81ea803df64bf58457a5dd4bf16#note_119455385
- Give up on g_log (g_message, etc.). This would be a major effort and doubtful we can do it in a time for 1.0.
- Use g_set_print_handler as described in https://stackoverflow.com/questions/43927373/force-utf-8-encoding-in-glibs-g-print
- Use g_log_set_handler as done in ui/dialog/messages.cpp
- Ask the GTK people.
Glib vs iostreams
Mix of glib output functions and std::cout/std::cerr. In principle mixing the two can cause problems but in practice it does not as by default std::cout/std::cerr are synced with stdio (std::sync_with_stdio).
- std::cout: 976
- std::cerr: 361
- g_log/g_logv: 23
- g_message: 312
- g_warning: 470
- g_critical: 47
- g_info: 72
- g_debug: 4
Our message dialog can intercept g_log, etc. and redirect it to the dialog. This is done through g_log_set_handler if "Capture log messages" is checked. As we intercept everything, we could just intercept stdout/stderr as a comment in the message code suggests. How do actually do this is not clear.
For std::cout only:
// Start redirection std::stringstream ss; std::streambuf *sb = std::cout.rdbuf(ss.rdbuf()); // End redirection std::cout.redbuf(sb);
char huge_string_buf; freopen("/dev/null", "a", stdout); setbuf(stdout, huge_string_buf);
Buffer could get filled up (shouldn't overflow).