chore: migrate updater console logs to Tauri logger

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-12 17:56:26 +00:00
parent 268ac9e81b
commit 43211b144b
7 changed files with 99 additions and 7 deletions

10
package-lock.json generated
View file

@ -19,6 +19,7 @@
"@tauri-apps/plugin-autostart": "^2.3.0", "@tauri-apps/plugin-autostart": "^2.3.0",
"@tauri-apps/plugin-dialog": "^2.7.1", "@tauri-apps/plugin-dialog": "^2.7.1",
"@tauri-apps/plugin-global-shortcut": "^2.2.0", "@tauri-apps/plugin-global-shortcut": "^2.2.0",
"@tauri-apps/plugin-log": "^2.9.0",
"@tauri-apps/plugin-opener": "^2.2.0", "@tauri-apps/plugin-opener": "^2.2.0",
"@tauri-apps/plugin-process": "^2.3.1", "@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.10.1", "@tauri-apps/plugin-updater": "^2.10.1",
@ -1244,6 +1245,15 @@
"@tauri-apps/api": "^2.11.0" "@tauri-apps/api": "^2.11.0"
} }
}, },
"node_modules/@tauri-apps/plugin-log": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-log/-/plugin-log-2.9.0.tgz",
"integrity": "sha512-Ql8okrnsguk0eDq1GvRfttFV5KaeW/7vcao6bdbkXCRJ1+2sWE15ZJvJVEKVANrOKy1mRngqC3IFIAP+wP5qSw==",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@tauri-apps/api": "^2.11.0"
}
},
"node_modules/@tauri-apps/plugin-opener": { "node_modules/@tauri-apps/plugin-opener": {
"version": "2.5.4", "version": "2.5.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.4.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.4.tgz",

View file

@ -25,6 +25,7 @@
"@tauri-apps/plugin-autostart": "^2.3.0", "@tauri-apps/plugin-autostart": "^2.3.0",
"@tauri-apps/plugin-dialog": "^2.7.1", "@tauri-apps/plugin-dialog": "^2.7.1",
"@tauri-apps/plugin-global-shortcut": "^2.2.0", "@tauri-apps/plugin-global-shortcut": "^2.2.0",
"@tauri-apps/plugin-log": "^2.9.0",
"@tauri-apps/plugin-opener": "^2.2.0", "@tauri-apps/plugin-opener": "^2.2.0",
"@tauri-apps/plugin-process": "^2.3.1", "@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.10.1", "@tauri-apps/plugin-updater": "^2.10.1",

69
src-tauri/Cargo.lock generated
View file

@ -32,6 +32,23 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "android_log-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d"
[[package]]
name = "android_logger"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb4e440d04be07da1f1bf44fb4495ebd58669372fe0cffa6e48595ac5bd88a3"
dependencies = [
"android_log-sys",
"env_filter",
"log",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -941,6 +958,16 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "env_filter"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2"
dependencies = [
"log",
"regex",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.2" version = "1.0.2"
@ -1004,6 +1031,15 @@ dependencies = [
"simd-adler32", "simd-adler32",
] ]
[[package]]
name = "fern"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29"
dependencies = [
"log",
]
[[package]] [[package]]
name = "field-offset" name = "field-offset"
version = "0.3.6" version = "0.3.6"
@ -2270,6 +2306,15 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "num_threads"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "objc2" name = "objc2"
version = "0.6.4" version = "0.6.4"
@ -3736,6 +3781,7 @@ dependencies = [
"tauri-plugin-autostart", "tauri-plugin-autostart",
"tauri-plugin-dialog", "tauri-plugin-dialog",
"tauri-plugin-global-shortcut", "tauri-plugin-global-shortcut",
"tauri-plugin-log",
"tauri-plugin-opener", "tauri-plugin-opener",
"tauri-plugin-process", "tauri-plugin-process",
"tauri-plugin-single-instance", "tauri-plugin-single-instance",
@ -4075,6 +4121,27 @@ dependencies = [
"thiserror 2.0.18", "thiserror 2.0.18",
] ]
[[package]]
name = "tauri-plugin-log"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6792296e6f389268016c77db21ebae1fc0568f2fccf88b1ec7e2ea71330afb4c"
dependencies = [
"android_logger",
"fern",
"log",
"objc2",
"objc2-foundation",
"serde",
"serde_json",
"serde_repr",
"swift-rs",
"tauri",
"tauri-plugin",
"thiserror 2.0.18",
"time",
]
[[package]] [[package]]
name = "tauri-plugin-opener" name = "tauri-plugin-opener"
version = "2.5.4" version = "2.5.4"
@ -4326,7 +4393,9 @@ checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
dependencies = [ dependencies = [
"deranged", "deranged",
"itoa", "itoa",
"libc",
"num-conv", "num-conv",
"num_threads",
"powerfmt", "powerfmt",
"serde_core", "serde_core",
"time-core", "time-core",

View file

@ -21,6 +21,7 @@ serde_json = "1"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
chrono = "0.4" chrono = "0.4"
futures = "0.3.32" futures = "0.3.32"
tauri-plugin-log = "2"
[profile.release] [profile.release]
strip = true strip = true

View file

@ -985,6 +985,7 @@ fn main() {
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_updater::Builder::new().build()) .plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_log::Builder::new().build())
.manage(DroppedFiles::default()) .manage(DroppedFiles::default())
.manage(DataDirGate::default()) .manage(DataDirGate::default())
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![

View file

@ -19,11 +19,15 @@ vi.mock('@tauri-apps/plugin-process', () => ({
relaunch: vi.fn(), relaunch: vi.fn(),
})); }));
vi.mock('@tauri-apps/plugin-log', () => ({
warn: vi.fn(),
error: vi.fn(),
info: vi.fn()
}));
describe('checkForUpdate', () => { describe('checkForUpdate', () => {
beforeEach(() => { beforeEach(() => {
vi.resetAllMocks(); vi.resetAllMocks();
vi.spyOn(console, 'info').mockImplementation(() => {});
vi.spyOn(console, 'warn').mockImplementation(() => {});
}); });
it('should return null if not in Tauri', async () => { it('should return null if not in Tauri', async () => {
@ -39,7 +43,8 @@ describe('checkForUpdate', () => {
const result = await checkForUpdate(); const result = await checkForUpdate();
expect(result).toBe('error'); expect(result).toBe('error');
expect(console.warn).toHaveBeenCalledWith('update check failed', expect.any(Error)); const { warn } = await import('@tauri-apps/plugin-log');
expect(warn).toHaveBeenCalledWith('update check failed: Error: Network error');
}); });
it('should return null if no update is available', async () => { it('should return null if no update is available', async () => {
@ -52,7 +57,8 @@ describe('checkForUpdate', () => {
const result = await checkForUpdate(); const result = await checkForUpdate();
expect(result).toBeNull(); expect(result).toBeNull();
expect(console.info).toHaveBeenCalledWith("no update: running 1.0.0, that's the latest published release"); const { info } = await import('@tauri-apps/plugin-log');
expect(info).toHaveBeenCalledWith("no update: running 1.0.0, that's the latest published release");
}); });
it('should return an update object if an update is available', async () => { it('should return an update object if an update is available', async () => {
@ -71,6 +77,9 @@ describe('checkForUpdate', () => {
if (result !== 'error' && result !== null) { if (result !== 'error' && result !== null) {
expect(result.version).toBe('1.1.0'); expect(result.version).toBe('1.1.0');
const { info } = await import('@tauri-apps/plugin-log');
expect(info).toHaveBeenCalledWith('update available: 1.0.0 -> 1.1.0');
const { relaunch } = await import('@tauri-apps/plugin-process'); const { relaunch } = await import('@tauri-apps/plugin-process');
await result.install(); await result.install();
expect(mockUpdate.downloadAndInstall).toHaveBeenCalled(); expect(mockUpdate.downloadAndInstall).toHaveBeenCalled();

View file

@ -1,3 +1,4 @@
import { info, warn } from "@tauri-apps/plugin-log";
import { isTauri } from "./storage"; import { isTauri } from "./storage";
interface AvailableUpdate { interface AvailableUpdate {
@ -19,10 +20,10 @@ export async function checkForUpdate(): Promise<AvailableUpdate | null | "error"
// visible in devtools console — the fastest way to tell "already on // visible in devtools console — the fastest way to tell "already on
// the latest published release" apart from "the check silently failed" // the latest published release" apart from "the check silently failed"
const { getVersion } = await import("@tauri-apps/api/app"); const { getVersion } = await import("@tauri-apps/api/app");
console.info(`no update: running ${await getVersion()}, that's the latest published release`); info(`no update: running ${await getVersion()}, that's the latest published release`);
return null; return null;
} }
console.info(`update available: ${update.currentVersion} -> ${update.version}`); info(`update available: ${update.currentVersion} -> ${update.version}`);
return { return {
version: update.version, version: update.version,
async install() { async install() {
@ -32,7 +33,7 @@ export async function checkForUpdate(): Promise<AvailableUpdate | null | "error"
}, },
}; };
} catch (e) { } catch (e) {
console.warn("update check failed", e); warn(`update check failed: ${e}`);
return "error"; return "error";
} }
} }