mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-22 13:34:18 +02:00
Merge pull request #238 from B0ney/fix/show-logs-on-windows
fix: allow the app to display logs when launced from the terminal on windows
This commit is contained in:
commit
2cccec28c2
2 changed files with 19 additions and 0 deletions
|
|
@ -35,6 +35,9 @@ iced = { version = "^0.10.0", features = ["advanced", "image"] }
|
|||
flate2 = { version = "^1", optional = true }
|
||||
tar = { version = "^0.4", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
win32console = "^0.1.5"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
|
|
|
|||
16
src/main.rs
16
src/main.rs
|
|
@ -27,6 +27,8 @@ fn main() -> iced::Result {
|
|||
}
|
||||
|
||||
pub fn setup_logger() -> Result<(), fern::InitError> {
|
||||
attach_windows_console();
|
||||
|
||||
let colors = ColoredLevelConfig::new().info(Color::Green);
|
||||
|
||||
let make_formatter = |use_colors: bool| {
|
||||
|
|
@ -75,3 +77,17 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// (Windows) Allow the application to display logs to the terminal
|
||||
/// regardless if it was compiled with `windows_subsystem = "windows"`.
|
||||
///
|
||||
/// This is a no-op when compiled to non-windows targets.
|
||||
fn attach_windows_console() {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use win32console::console::WinConsole;
|
||||
|
||||
const ATTACH_PARENT_PROCESS: u32 = 0xFFFFFFFF;
|
||||
let _ = WinConsole::attach_console(ATTACH_PARENT_PROCESS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue