New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log_to_console now logs to console in Windows #11834
Conversation
common/ux-window.cpp
Outdated
@@ -63,7 +63,14 @@ namespace rs2 | |||
config_file::instance().set_default(configurations::window::saved_size, false); | |||
|
|||
config_file::instance().set_default(configurations::viewer::is_measuring, false); | |||
config_file::instance().set_default(configurations::viewer::log_to_console, true); | |||
config_file::instance().set_default(configurations::viewer::log_to_console, | |||
#ifdef WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like bad alignment.
I suggest
auto default_log_to_console = true;
// In Windows, there is no console by default
#ifdef WIN32
default_log_to_console = false;
#endif
config_file::instance().set_default(configurations::viewer::log_to_console, default_log_to_console );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change
src/log.h
Outdated
@@ -180,6 +181,8 @@ namespace librealsense | |||
|
|||
void log_to_console(rs2_log_severity min_severity) | |||
{ | |||
if( min_severity != RS2_LOG_SEVERITY_NONE ) | |||
rsutils::os::ensure_console(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test how python on Windows behave with this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything behaves the same -- python is usually started from a console.
Only thing new is that, if there is no console, a new window will pop up (on Windows).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we could do is create a console if the build is a debug build, with the idea being that, when debugging, you do want to see the debug in a separate window...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current implementation is better.
Let's not surprise the users.
The viewer has a setting:
The default is to log to console, minimum level Warning.
This did nothing in Windows. It does not affect the Debug Console Window in the Viewer.
This changes:
rsutils
function toensure_console()
which we now use when callinglog_to_console
NOTE that I had to make this work in both Shared and Static builds. In the former, anything outside of librealsense will not affect the librealsense logs - so I had to place the console-opening inside librealsense (originally it was only in the Viewer).