Skip to content

Commit 4762113

Browse files
author
Jason Mobarak
authored
Disable attach_console unless indicated [CPP-792] (#654)
* Disable attach_console unless indicated * disable attach_console in server code too...
1 parent 7d8a270 commit 4762113

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

console_backend/src/server.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ use crate::server_recv_thread::server_recv_thread;
1414
use crate::shared_state::SharedState;
1515
use crate::utils::{refresh_connection_frontend, refresh_loggingbar};
1616

17-
pub(crate) fn attach_console() {
18-
#[cfg(target_os = "windows")]
19-
{
20-
use windows::Win32::System::Console::AttachConsole;
21-
unsafe {
22-
AttachConsole(u32::MAX).as_bool();
17+
pub fn attach_console() {
18+
if std::env::var("SWIFTNAV_CONSOLE_DEBUG").is_ok() {
19+
#[cfg(target_os = "windows")]
20+
{
21+
use windows::Win32::System::Console::AttachConsole;
22+
unsafe {
23+
AttachConsole(u32::MAX).as_bool();
24+
}
2325
}
2426
}
2527
}

entrypoint/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ lazy_static! {
2222

2323
#[cfg(feature = "entrypoint")]
2424
pub fn attach_console() {
25-
#[cfg(target_os = "windows")]
26-
{
27-
use windows::Win32::System::Console::AttachConsole;
28-
unsafe {
29-
AttachConsole(u32::MAX).as_bool();
25+
if std::env::var("SWIFTNAV_CONSOLE_DEBUG").is_ok() {
26+
#[cfg(target_os = "windows")]
27+
{
28+
use windows::Win32::System::Console::AttachConsole;
29+
unsafe {
30+
AttachConsole(u32::MAX).as_bool();
31+
}
3032
}
3133
}
3234
}

0 commit comments

Comments
 (0)