The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(host): write every run down to a file
Jareer85c6fa5386f8
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex e407a208..441194c7 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -65,6 +65,12 @@ A maintainer then runs the *Mirror models* workflow, which fetches the model,records its digest in both places and publishes it to the mirror the appdownloads from.+Write what happens through the `log` facade — `log::info!`, `log::warn!`,+`log::error!` — rather than to standard output or standard error. Every run+writes `<app data>/logs/concat-<when>.log`, and a packaged build has no+terminal for anything that goes anywhere else; `CONCAT_LOG=debug` turns the+level up. See `engine/crates/concat-host/src/logs.rs`.+New source files need a licence header — see below. Match the style of the codearound you; the engine avoids cleverness on purpose.diff --git a/README.md b/README.mdindex ab7f52b3..03be8b8d 100644--- a/README.md+++ b/README.md@@ -49,6 +49,8 @@ Concat is currently in **Beta version (pre-release)**. **Download** the latest b**Portable:** the Windows and Linux builds are plain archives. To keep everything on the stick or in the folder you unpacked into, make a folder named `portable` beside the `concat` executable: settings, recents and downloaded models then live there and nothing is written to the user profile.+**Reporting something:** every run writes a log, and Settings › About has the button that opens it along with the one that copies your system information. Attach both to an [issue](https://github.com/jub0t/Concat/issues) and the report arrives with everything it needs. The last ten runs are kept, so yesterday's is still there; nothing is ever sent anywhere on its own.+**Platform support:**- ✅ **Windows** — testeddiff --git a/engine/Cargo.lock b/engine/Cargo.lockindex d6cdf556..4b849b7c 100644--- a/engine/Cargo.lock+++ b/engine/Cargo.lock@@ -1154,6 +1154,7 @@ dependencies = ["concat-speech","concat-vision","image",+ "log","opener","png 0.17.16","pollster",@@ -1246,6 +1247,7 @@ dependencies = ["concat-text","concat-vision","cpal",+ "log","memmap2","serde","serde_json",diff --git a/engine/crates/concat-android/src/lib.rs b/engine/crates/concat-android/src/lib.rsindex df216a50..1a2df729 100644--- a/engine/crates/concat-android/src/lib.rs+++ b/engine/crates/concat-android/src/lib.rs@@ -39,22 +39,32 @@ mod activity {}}- /// Routes the log facade, panics and stderr to logcat.- pub fn open_logcat() {- android_logger::init_once(+ /// Routes the log facade, panics and stderr to logcat, and to a file.+ ///+ /// logcat is what a phone on a cable gives you, and nothing else is as+ /// good while there is a cable. A phone in somebody's hand has none, so+ /// the same lines are written into the app's own storage as well; the+ /// window's Settings is where they are found. Called after+ /// [`name_directories`], because that is what says where storage is.+ pub fn open_log() {+ // Info is logcat's floor, as it always was; CONCAT_LOG is the+ // ceiling over both sinks, so turning the file up to debug does not+ // also flood logcat, and turning everything down still quiets it.+ let logcat = android_logger::AndroidLogger::new(android_logger::Config::default().with_max_level(log::LevelFilter::Info).with_tag("concat"),);- std::panic::set_hook(Box::new(|info| {- log::error!("panic: {info}");- }));+ concat::open_logging(Some(Box::new(logcat)));forward_stderr();}/// Everything written to stderr is read back off a pipe and logged a- /// line at a time, so `eprintln!` reaches logcat without every call- /// site knowing about phones.+ /// line at a time, so a stray `eprintln!` in a dependency reaches logcat+ /// without that dependency knowing about phones. The app's own lines do+ /// not come this way - they go through the facade, which on a phone+ /// deliberately leaves stderr alone so a line cannot come back round+ /// this pipe and log itself forever.fn forward_stderr() {use std::os::fd::FromRawFd;let mut ends = [0i32; 2];@@ -90,8 +100,9 @@ mod activity {#[cfg(target_os = "android")]#[unsafe(no_mangle)]fn android_main(app: slint::android::AndroidApp) {- activity::open_logcat();+ // Directories first: the log file is written into one of them.activity::name_directories(&app);+ activity::open_log();log::info!("Concat {} starting", env!("CARGO_PKG_VERSION"));if let Err(error) = slint::android::init(app) {log::error!("could not start the Android backend: {error}");diff --git a/engine/crates/concat-host/Cargo.toml b/engine/crates/concat-host/Cargo.tomlindex ace13f13..2e3c29dc 100644--- a/engine/crates/concat-host/Cargo.toml+++ b/engine/crates/concat-host/Cargo.toml@@ -25,6 +25,9 @@ ureq = "2"# A finished download is checked against the digest its table carries# before anything is allowed to call it installed; see models.rs.sha2 = "0.10"+# The log facade. The engine writes `log::warn!` and logs.rs is what puts+# the line in a file; a phone puts it in logcat as well.+log = { version = "0.4", features = ["std"] }# The CPU compositor draws the monitor's frame; the wgpu one is behind# `gpu`, so a headless host pays for no GPU tree.concat-render.workspace = truediff --git a/engine/crates/concat-host/src/lib.rs b/engine/crates/concat-host/src/lib.rsindex 19429f9d..76964d14 100644--- a/engine/crates/concat-host/src/lib.rs+++ b/engine/crates/concat-host/src/lib.rs@@ -23,6 +23,7 @@ pub mod cutout;pub mod dirs;pub mod export;pub mod jobs;+pub mod logs;pub mod media;pub mod models;pub mod playback;diff --git a/engine/crates/concat-host/src/logs.rs b/engine/crates/concat-host/src/logs.rsnew file mode 100644index 00000000..5e7b2ab3--- /dev/null+++ b/engine/crates/concat-host/src/logs.rs@@ -0,0 +1,439 @@+// SPDX-License-Identifier: AGPL-3.0-or-later+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors++//! What the app writes down about its own run.+//!+//! A packaged editor has no terminal. The `.app` a person double-clicks, the+//! `.exe` a launcher starts and the window a desktop entry opens all have+//! their standard error wired to nowhere, so every line the engine writes+//! about a failed decode, a lost device or a refused file went straight into+//! the dark, and a report of "it stopped" came with nothing behind it. This+//! is where those lines go instead.+//!+//! One file per run, in `<app data>/logs/`, named for the instant it opened.+//! A run is the unit because that is the unit a person reports: *this* time I+//! opened it, *this* is what it did. The newest [`KEEP`] files stay and the+//! rest are deleted as each run starts, so the folder is bounded without a+//! sweeper, and each file stops growing at [`CAP`] so a loop that logs on+//! every frame cannot fill a disk.+//!+//! Everything goes through the `log` facade, so a crate writes `log::warn!`+//! and neither knows nor cares that a file is on the other end. The lines+//! reach a console as well as the file - standard error on a desktop, so a+//! run from a terminal reads exactly as it did, and logcat on a phone.+//!+//! What ends up here is the app's own account of itself - not a profile, not+//! telemetry. Nothing is sent anywhere. The file is the user's, in their own+//! data folder, and Settings › About is where they can go and find it.++use std::fmt::Write as _;+use std::io::Write as _;+use std::path::{Path, PathBuf};+use std::sync::{Mutex, OnceLock};++use crate::dirs::AppDirs;++/// How many runs' logs are kept. Ten covers "it did it again yesterday"+/// without the folder ever being something a person has to think about.+pub const KEEP: usize = 10;++/// How much one run may write before the file stops growing, in bytes.+pub const CAP: u64 = 16 * 1024 * 1024;++/// The environment variable that overrides the level: `error`, `warn`,+/// `info`, `debug` or `trace`. Info without one.+pub const LEVEL_VARIABLE: &str = "CONCAT_LOG";++/// The file this run is writing to, once [`open`] has been called.+static CURRENT: OnceLock<PathBuf> = OnceLock::new();++/// Where the logs are kept.+pub fn folder(dirs: &AppDirs) -> PathBuf {+ dirs.data.join("logs")+}++/// The file this run is writing to, or `None` when there is none - [`open`]+/// was never called, or it could not make one.+pub fn current() -> Option<&'static Path> {+ CURRENT.get().map(PathBuf::as_path)+}++/// Opens this run's file and makes it the process's logger.+///+/// Call once, as early as a run can: anything logged before this is lost.+/// `extra` is where the lines go besides the file - logcat on a phone - and+/// `None` on a desktop, which puts them on standard error instead, so a run+/// from a terminal reads the way it always did.+///+/// Returns the file it opened. An `Err` means there is no file this run -+/// an unwritable data folder, a second call - and is worth reporting, but it+/// is never worth refusing to start over: the logger is installed either+/// way, and standard error still has everything.+pub fn open(dirs: &AppDirs, extra: Option<Box<dyn log::Log>>) -> Result<PathBuf, String> {+ let opened = begin(dirs);+ let sink = match &opened {+ Ok((path, file)) => match file.try_clone() {+ Ok(file) => {+ let _ = CURRENT.set(path.clone());+ Some(Sink {+ file,+ written: 0,+ stopped: false,+ })+ }+ Err(_) => None,+ },+ Err(_) => None,+ };+ install(sink, extra)?;+ opened.map(|(path, _)| path)+}++/// The logger with no file: the console alone.+///+/// For a run with nowhere to put a file - a machine whose data directory+/// cannot be located at all. The facade still has to lead somewhere, or+/// every line the engine writes disappears silently instead of loudly.+pub fn open_console(extra: Option<Box<dyn log::Log>>) -> Result<(), String> {+ install(None, extra)+}++/// Makes a logger out of the pieces and hands it to the facade.+fn install(sink: Option<Sink>, extra: Option<Box<dyn log::Log>>) -> Result<(), String> {+ let level = level_from_environment();+ let logger = Logger {+ sink: sink.map(Mutex::new),+ extra,+ };+ log::set_boxed_logger(Box::new(logger))+ .map(|()| log::set_max_level(level))+ .map_err(|_| "a logger was already installed".to_owned())?;+ log::info!(+ "Concat {} · {} {} · {level}",+ env!("CARGO_PKG_VERSION"),+ std::env::consts::OS,+ std::env::consts::ARCH,+ );+ Ok(())+}++/// Sends panics to the log before they reach wherever they were going.+///+/// A panic is the one failure that never passes through a `Result`, and in a+/// packaged build it is also the one that leaves nothing behind: the message+/// goes to a standard error nobody is reading and the window disappears. The+/// hook that was there still runs afterwards, so a terminal still prints the+/// panic and a backtrace exactly as before.+pub fn catch_panics() {+ let previous = std::panic::take_hook();+ std::panic::set_hook(Box::new(move |info| {+ let where_ = info+ .location()+ .map_or_else(|| "somewhere".to_owned(), |at| at.to_string());+ log::error!("panic at {where_}: {}", info);+ previous(info);+ }));+}++/// This run's file: the folder made, the older runs pruned, the file opened.+fn begin(dirs: &AppDirs) -> Result<(PathBuf, std::fs::File), String> {+ let folder = folder(dirs);+ std::fs::create_dir_all(&folder)+ .map_err(|error| format!("could not create {}: {error}", folder.display()))?;+ prune(&folder);+ let path = folder.join(format!("concat-{}.log", stamp(now(), Stamp::File)));+ let file = std::fs::OpenOptions::new()+ .create(true)+ .append(true)+ .open(&path)+ .map_err(|error| format!("could not open {}: {error}", path.display()))?;+ Ok((path, file))+}++/// Deletes all but the newest [`KEEP`] runs.+///+/// By name, which for this name is by time: nothing depends on a file system+/// that reports modification times, and a file copied out and back keeps its+/// place in the order.+fn prune(folder: &Path) {+ let Ok(entries) = std::fs::read_dir(folder) else {+ return;+ };+ let mut ours: Vec<PathBuf> = entries+ .flatten()+ .map(|entry| entry.path())+ .filter(|path| {+ path.file_name()+ .and_then(|name| name.to_str())+ .is_some_and(|name| name.starts_with("concat-") && name.ends_with(".log"))+ })+ .collect();+ if ours.len() < KEEP {+ return;+ }+ ours.sort();+ // One short of KEEP, because the run doing the pruning is about to+ // make its own.+ let doomed = ours.len().saturating_sub(KEEP.saturating_sub(1));+ for path in ours.into_iter().take(doomed) {+ let _ = std::fs::remove_file(path);+ }+}++fn level_from_environment() -> log::LevelFilter {+ match std::env::var(LEVEL_VARIABLE)+ .unwrap_or_default()+ .to_ascii_lowercase()+ .as_str()+ {+ "error" => log::LevelFilter::Error,+ "warn" => log::LevelFilter::Warn,+ "debug" => log::LevelFilter::Debug,+ "trace" => log::LevelFilter::Trace,+ "off" => log::LevelFilter::Off,+ _ => log::LevelFilter::Info,+ }+}++/// The open file and how much of its allowance is gone.+struct Sink {+ file: std::fs::File,+ written: u64,+ /// Set once the cap is reached; the line that says so is written once.+ stopped: bool,+}++/// The process's logger: a file, standard error, and on a phone one more.+struct Logger {+ /// `None` when this run has no file; standard error still has it all.+ sink: Option<Mutex<Sink>>,+ extra: Option<Box<dyn log::Log>>,+}++impl log::Log for Logger {+ fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {+ metadata.level() <= log::max_level()+ }++ fn log(&self, record: &log::Record<'_>) {+ if !self.enabled(record.metadata()) {+ return;+ }+ let line = format(record);+ // Standard error keeps its copy, so a run from a terminal reads the+ // way it always did - but only when the caller named nowhere else.+ // A caller that hands over a console of its own already has one, and+ // on a phone that console is fed by a pipe off standard error: a line+ // written there would come back through it and write itself forever.+ if self.extra.is_none() {+ eprintln!("{line}");+ }+ if let Some(sink) = &self.sink {+ let mut sink = sink.lock().unwrap_or_else(|poisoned| poisoned.into_inner());+ if sink.stopped {+ return;+ }+ if sink.written >= CAP {+ sink.stopped = true;+ let _ = writeln!(+ sink.file,+ "[this run passed {CAP} bytes of log; the rest is not written down]"+ );+ return;+ }+ if writeln!(sink.file, "{line}").is_ok() {+ sink.written += line.len() as u64 + 1;+ }+ }+ if let Some(extra) = &self.extra {+ extra.log(record);+ }+ }++ fn flush(&self) {+ if let Some(sink) = &self.sink {+ let mut sink = sink.lock().unwrap_or_else(|poisoned| poisoned.into_inner());+ let _ = sink.file.flush();+ }+ if let Some(extra) = &self.extra {+ extra.flush();+ }+ }+}++/// One line: when, how bad, which thread, which module, and what happened.+///+/// The thread is in there because the answer to a good half of what gets+/// logged is "which thread was that on" - a decode worker, the artwork lane,+/// the event loop - and a line that does not say cannot be asked later.+fn format(record: &log::Record<'_>) -> String {+ let thread = std::thread::current();+ let who = thread.name().unwrap_or("?").to_owned();+ let mut line = String::with_capacity(128);+ let _ = write!(+ line,+ "{} {:<5} [{}] {}: {}",+ stamp(now(), Stamp::Line),+ record.level(),+ who,+ record.target(),+ record.args()+ );+ line+}++/// Seconds and milliseconds since the epoch, or zero if the clock is before+/// it - which is not a case worth a branch anywhere else.+fn now() -> (i64, u32) {+ match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) {+ Ok(since) => (since.as_secs() as i64, since.subsec_millis()),+ Err(_) => (0, 0),+ }+}++/// Which of the two shapes a stamp is written in.+#[derive(Clone, Copy, PartialEq, Eq)]+enum Stamp {+ /// `20260914-123456`, for a file name: sorts as it reads, and has+ /// nothing in it a file system anywhere objects to.+ File,+ /// `2026-09-14 12:34:56.789Z`, for a line in one.+ Line,+}++/// UTC, always: a log read by somebody else is a log whose times mean the+/// same thing in both places.+fn stamp((seconds, millis): (i64, u32), shape: Stamp) -> String {+ let days = seconds.div_euclid(86_400);+ let rest = seconds.rem_euclid(86_400);+ let (hour, minute, second) = (rest / 3600, (rest % 3600) / 60, rest % 60);+ let (year, month, day) = civil(days);+ match shape {+ Stamp::File => format!("{year:04}{month:02}{day:02}-{hour:02}{minute:02}{second:02}"),+ Stamp::Line => {+ format!("{year:04}-{month:02}-{day:02} {hour:02}:{minute:02}:{second:02}.{millis:03}Z")+ }+ }+}++/// The calendar date `days` after 1970-01-01, by Howard Hinnant's+/// `civil_from_days`: the years are shifted to start in March so that the+/// leap day lands at the end of one and the month lengths fall into a+/// pattern with no table in it.+fn civil(days: i64) -> (i64, u32, u32) {+ let shifted = days + 719_468;+ let era = shifted.div_euclid(146_097);+ let day_of_era = shifted.rem_euclid(146_097);+ let year_of_era =+ (day_of_era - day_of_era / 1460 + day_of_era / 36_524 - day_of_era / 146_096) / 365;+ let year = year_of_era + era * 400;+ let day_of_year = day_of_era - (365 * year_of_era + year_of_era / 4 - year_of_era / 100);+ let march_month = (5 * day_of_year + 2) / 153;+ let day = (day_of_year - (153 * march_month + 2) / 5 + 1) as u32;+ let month = if march_month < 10 {+ march_month + 3+ } else {+ march_month - 9+ } as u32;+ (year + i64::from(month <= 2), month, day)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn the_epoch_and_a_leap_day_come_out_right() {+ assert_eq!(civil(0), (1970, 1, 1));+ // 2024-02-29, a leap day, and the day after it.+ assert_eq!(civil(19_782), (2024, 2, 29));+ assert_eq!(civil(19_783), (2024, 3, 1));+ // 2000 is a leap year and 1900 was not; the era arithmetic is what+ // gets that pair wrong when it is wrong at all.+ assert_eq!(civil(11_016), (2000, 2, 29));+ assert_eq!(civil(-25_508), (1900, 3, 1));+ }++ #[test]+ fn a_stamp_reads_as_a_date_in_both_shapes() {+ let at = (1_726_316_096, 789);+ assert_eq!(stamp(at, Stamp::Line), "2024-09-14 12:14:56.789Z");+ assert_eq!(stamp(at, Stamp::File), "20240914-121456");+ // A file name sorts the way the runs happened.+ assert!(stamp((0, 0), Stamp::File) < stamp(at, Stamp::File));+ }++ #[test]+ fn pruning_keeps_the_newest_and_leaves_everything_else_alone() {+ let folder = std::env::temp_dir().join(format!("concat-logs-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&folder);+ std::fs::create_dir_all(&folder).expect("a temp dir");+ for index in 0..KEEP + 5 {+ std::fs::write(+ folder.join(format!("concat-2026091{index:02}-000000.log")),+ "x",+ )+ .expect("a log");+ }+ // Not ours, and not to be touched.+ std::fs::write(folder.join("notes.txt"), "x").expect("a file");+ prune(&folder);++ let mut left: Vec<String> = std::fs::read_dir(&folder)+ .expect("reads")+ .flatten()+ .filter_map(|entry| entry.file_name().into_string().ok())+ .collect();+ left.sort();+ assert!(left.contains(&"notes.txt".to_owned()));+ let ours: Vec<&String> = left+ .iter()+ .filter(|name| name.starts_with("concat-"))+ .collect();+ assert_eq!(ours.len(), KEEP - 1, "{ours:?}");+ // The ones kept are the last ones written.+ assert!(ours.iter().all(|name| name.as_str() >= "concat-20260906"));+ let _ = std::fs::remove_dir_all(&folder);+ }++ /// The one test that installs the process logger, because there is only+ /// one to install: everything from the facade down to a line in a file.+ #[test]+ fn a_line_written_through_the_facade_lands_in_the_file() {+ let root = std::env::temp_dir().join(format!("concat-open-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&root);+ std::fs::create_dir_all(&root).expect("a temp dir");+ let dirs = AppDirs::under(&root);++ let path = open(&dirs, None).expect("a log file");+ assert_eq!(path.parent(), Some(folder(&dirs).as_path()));+ assert_eq!(current(), Some(path.as_path()));++ log::warn!("the kettle is broken");+ log::logger().flush();++ let written = std::fs::read_to_string(&path).expect("reads back");+ // The header the install writes, and then the line.+ assert!(written.contains(env!("CARGO_PKG_VERSION")), "{written}");+ assert!(written.contains("WARN"), "{written}");+ assert!(written.contains("the kettle is broken"), "{written}");+ // Every line says when, on which thread, and out of which module.+ let line = written+ .lines()+ .find(|line| line.contains("the kettle is broken"))+ .expect("the line");+ assert!(line.starts_with("20"), "{line}");+ assert!(line.contains("concat_host::logs"), "{line}");++ // A second call cannot take the facade a second time, and says so+ // rather than pretending.+ assert!(open(&dirs, None).is_err());+ let _ = std::fs::remove_dir_all(&root);+ }++ #[test]+ fn a_folder_hangs_off_the_data_directory() {+ let dirs = AppDirs::under(Path::new("/tmp/concat-test"));+ assert_eq!(folder(&dirs), Path::new("/tmp/concat-test/logs"));+ }+}diff --git a/engine/crates/concat-host/src/playback.rs b/engine/crates/concat-host/src/playback.rsindex 43327563..7d67f23f 100644--- a/engine/crates/concat-host/src/playback.rs+++ b/engine/crates/concat-host/src/playback.rs@@ -333,7 +333,7 @@ pub struct Playback {/// silence. Logged for the console, reported for the window's toast - the/// difference between "audio is broken" and a bug report that names a file.fn report(events: &dyn PlaybackEvents, message: String) {- eprintln!("concat: {message}");+ log::warn!("{message}");events.error(message);}@@ -878,7 +878,7 @@ fn supervise_stream({// Informational only - switching outputs is a// normal act, not an error toast.- eprintln!("concat: audio device changed to {current}; rebuilding");+ log::info!("audio device changed to {current}; rebuilding");break;}}diff --git a/engine/crates/concat-host/src/titles.rs b/engine/crates/concat-host/src/titles.rsindex 4b3cf426..a0dbfaed 100644--- a/engine/crates/concat-host/src/titles.rs+++ b/engine/crates/concat-host/src/titles.rs@@ -95,7 +95,7 @@ impl Titles {let (path, art) = match self.painted(project, &text, width, height) {Ok(art) => art,Err(error) => {- eprintln!("concat: title {}: {error}", clip.id);+ log::warn!("title {}: {error}", clip.id);continue;}};diff --git a/engine/crates/concat/Cargo.toml b/engine/crates/concat/Cargo.tomlindex 7abc7fa7..0770755f 100644--- a/engine/crates/concat/Cargo.toml+++ b/engine/crates/concat/Cargo.toml@@ -82,6 +82,9 @@ slint = { version = "1.17", default-features = false, features = [# Writes the card still an imported look gets, rendered here from the# reference picture through the table.png = "0.17"+# The log facade. The window writes `log::warn!`; where that ends up is+# concat-host's logs.rs, opened by whichever entry point started this run.+log = "0.4"# The one device: created in gpu.rs, handed to Slint and to the monitor.wgpu.workspace = truepollster.workspace = truediff --git a/engine/crates/concat/locales/en.json b/engine/crates/concat/locales/en.jsonindex 3b582f22..9c9bc42f 100644--- a/engine/crates/concat/locales/en.json+++ b/engine/crates/concat/locales/en.json@@ -139,6 +139,7 @@"Could not import {0}: {1}": "Could not import {0}: {1}","Could not save: {0}": "Could not save: {0}","Could not show the file: {0}": "Could not show the file: {0}",+ "Could not show the log: {0}": "Could not show the log: {0}","Create": "Create","Creating…": "Creating…","Crisper edges.": "Crisper edges.",@@ -533,6 +534,7 @@"Shifts the picture towards daylight shade.": "Shifts the picture towards daylight shade.","Show in folder": "Show in folder","Show lane": "Show lane",+ "Show the log": "Show the log","Showing the look over the picture. Double-click the card, or its plus, to lay it on the timeline": "Showing the look over the picture. Double-click the card, or its plus, to lay it on the timeline","Silent": "Silent","Similarity": "Similarity",diff --git a/engine/crates/concat/src/lib.rs b/engine/crates/concat/src/lib.rsindex c0bd90b5..90bfe1e7 100644--- a/engine/crates/concat/src/lib.rs+++ b/engine/crates/concat/src/lib.rs@@ -48,6 +48,26 @@ use host::{Host, Shell};use studio::{Models, OUTPUTS, RESOLUTIONS, START_RATES, Studio};use ui::*;+/// Opens this run's log file and makes it where the app writes things down.+///+/// Each entry point calls this before [`run`], because each knows where its+/// console is: a desktop has a standard error, a phone has logcat, and that+/// is what arrives here as `extra`. Everything after it - the engine's+/// warnings, a panic, the lines below - is written down in+/// `<app data>/logs/` as well as said out loud. See `concat_host::logs`.+pub fn open_logging(extra: Option<Box<dyn log::Log>>) {+ concat_host::logs::catch_panics();+ let opened = match concat_host::AppDirs::locate() {+ Ok(dirs) => concat_host::logs::open(&dirs, extra).map(|_| ()),+ // No directory at all: the facade still has to lead somewhere, or+ // every line disappears silently rather than loudly.+ Err(error) => concat_host::logs::open_console(extra).and(Err(error)),+ };+ if let Err(error) = opened {+ log::warn!("this run is not being written to a file: {error}");+ }+}+/// Builds the window, binds it to the engine, and runs it until it closes.pub fn run() -> Result<(), slint::PlatformError> {let gpu = platform::select_backend()?;@@ -55,7 +75,7 @@ pub fn run() -> Result<(), slint::PlatformError> {let host = match Host::start(gpu) {Ok(host) => host,Err(error) => {- eprintln!("concat: {error}");+ log::error!("{error}");return Err(slint::PlatformError::Other(error));}};@@ -63,7 +83,7 @@ pub fn run() -> Result<(), slint::PlatformError> {// The user's own packages - imported looks - sit beside the built-ins// from the first frame. One that will not load is reported and skipped.for error in concat_effects::Catalogue::install(&Studio::looks_dir(&host.dirs)) {- eprintln!("concat: look: {error}");+ log::warn!("look: {error}");}let app = App::new()?;@@ -942,6 +962,17 @@ pub fn run() -> Result<(), slint::PlatformError> {app.on_settings_page_changed(on_window!(|state, index: i32| {state.settings.tab = index;}));+ app.on_settings_show_log(on_window!(|state| {+ // The file this run is writing, when there is one, so the manager+ // opens with it selected; the folder when there is not, which is+ // still where the previous runs are.+ let target = concat_host::logs::current()+ .map(std::path::Path::to_path_buf)+ .unwrap_or_else(|| concat_host::logs::folder(&state.host.dirs));+ if let Err(error) = platform::reveal(&target.to_string_lossy()) {+ state.notify(&i18n::tf("Could not show the log: {0}", &[&error]), true);+ }+ }));app.on_settings_language_changed(on_window!(|state, index: i32| {let index = index.max(0) as usize;if let Some(language) = state.languages.get(index).cloned() {diff --git a/engine/crates/concat/src/main.rs b/engine/crates/concat/src/main.rsindex 265090d8..c3b56d3a 100644--- a/engine/crates/concat/src/main.rs+++ b/engine/crates/concat/src/main.rs@@ -8,5 +8,8 @@#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]fn main() -> Result<(), slint::PlatformError> {+ // A desktop's console is its standard error, which a packaged build+ // has wired to nowhere; hence the file underneath it.+ concat::open_logging(None);concat::run()}diff --git a/engine/crates/concat/src/platform.rs b/engine/crates/concat/src/platform.rsindex a1fdc9f7..410a856d 100644--- a/engine/crates/concat/src/platform.rs+++ b/engine/crates/concat/src/platform.rs@@ -31,7 +31,7 @@ pub fn select_backend() -> Result<Option<Gpu>, PlatformError> {// the backend is selected with it.let gpu = Gpu::acquire();if gpu.is_none() {- eprintln!("concat: no GPU adapter; the monitor composites on the CPU");+ log::warn!("no GPU adapter; the monitor composites on the CPU");}let mut selector = slint::BackendSelector::new().backend_name("winit".into());@@ -203,6 +203,11 @@ pub fn pick_files(title: &str, filter: Option<(&str, &[&str])>) -> Option<Vec<Pa}/// Shows a written file in the platform's file manager.+///+/// A phone has no file manager to hand a path to, and says so rather than+/// appearing to work: a control that silently does nothing is worse than one+/// that explains itself. The path is in the message, which is the part a+/// developer on a cable can still use.pub fn reveal(path: &str) -> Result<(), String> {#[cfg(not(any(target_os = "android", target_os = "ios")))]{@@ -210,7 +215,8 @@ pub fn reveal(path: &str) -> Result<(), String> {}#[cfg(any(target_os = "android", target_os = "ios"))]{- let _ = path;- Ok(())+ Err(format!(+ "this device has no file manager to open {path} with"+ ))}}diff --git a/engine/crates/concat/src/studio.rs b/engine/crates/concat/src/studio.rsindex 56fdce39..6824158d 100644--- a/engine/crates/concat/src/studio.rs+++ b/engine/crates/concat/src/studio.rs@@ -1938,7 +1938,7 @@ impl Studio {match picture {Ok(image) => studio.preview = image,Err(error) => {- eprintln!("concat: preview: {error}");+ log::warn!("preview: {error}");if !studio.preview_failed {studio.preview_failed = true;studio.notify(&tf("Preview failed: {0}", &[&error]), true);@@ -4710,7 +4710,7 @@ impl Studio {match Session::open_info(&info) {Ok(session) => {if let Err(error) = projects::remember(&self.host.dirs.config, &info) {- eprintln!("concat: {error}");+ log::warn!("{error}");}self.pause();self.session = Some(session);@@ -5666,7 +5666,7 @@ impl Studio {return;}for error in Catalogue::install(&dir) {- eprintln!("concat: look: {error}");+ log::warn!("look: {error}");}self.library[0].query.clear();self.notify(diff --git a/engine/crates/concat/ui/app.slint b/engine/crates/concat/ui/app.slintindex 4a54bae7..de88a64b 100644--- a/engine/crates/concat/ui/app.slint+++ b/engine/crates/concat/ui/app.slint@@ -183,6 +183,7 @@ export component App inherits Window {callback settings-closed();callback settings-page-changed(index: int);+ callback settings-show-log();callback settings-language-changed(index: int);callback settings-theme-changed(dark: bool);callback settings-playhead-stops-changed(on: bool);@@ -460,6 +461,7 @@ export component App inherits Window {closed => { root.settings-closed(); }page-changed(index) => { root.settings-page-changed(index); }+ show-log => { root.settings-show-log(); }language-changed(index) => { root.settings-language-changed(index); }theme-changed(dark) => { root.settings-theme-changed(dark); }playhead-stops-changed(on) => { root.settings-playhead-stops-changed(on); }diff --git a/engine/crates/concat/ui/dialogs/settings.slint b/engine/crates/concat/ui/dialogs/settings.slintindex 73e879b2..3cf70f35 100644--- a/engine/crates/concat/ui/dialogs/settings.slint+++ b/engine/crates/concat/ui/dialogs/settings.slint@@ -332,6 +332,8 @@ export component SettingsDialog inherits Modal {in property <string> system-report;callback page-changed(index: int);+ /// Opens the folder this run's log is being written into.+ callback show-log();callback language-changed(index: int);/// The theme, chosen rather than flipped. A toggle in the strip could only/// say "the other one"; a page with two named options can say which one is@@ -586,6 +588,18 @@ export component SettingsDialog inherits Modal {HorizontalLayout {alignment: end;+ spacing: Theme.gap;++ // The other half of a report: the block above says+ // what this machine is, the log says what the app+ // did on it. A run writes one file, and the last ten+ // runs are in the folder this opens.+ IconButton {+ glyph: Glyph.folder;+ label: I18n.t("Show the log");+ icon-size: 13px;+ clicked => { root.show-log(); }+ }IconButton {glyph: Glyph.copy;