1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2026 Michael Wilson <mike@mdwn.dev>
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//
use mtrack::cli;
use mtrack::tui;
#[tokio::main]
async fn main() {
let tui_mode = std::env::args().any(|a| a == "--tui");
// Initialize tracing with a filter that sets default logging to off, with mtrack at info level.
// This prevents noisy INFO messages from symphonia crates (which are suppressed by the default "off").
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("off,mtrack=info"));
if tui_mode {
// In TUI mode, route tracing output to an in-TUI log panel
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
let tui_layer = tui::logging::init_tui_logging(1000);
tracing_subscriber::registry()
.with(filter)
.with(tui_layer)
.init();
} else {
// Headless: log to stderr AND capture in ring buffer for web UI log streaming
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
let tui_layer = tui::logging::init_tui_logging(1000);
let fmt_layer = tracing_subscriber::fmt::layer();
tracing_subscriber::registry()
.with(filter)
.with(fmt_layer)
.with(tui_layer)
.init();
}
if let Err(e) = cli::run(tui_mode).await {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}