From 9629c2f4f90a56b5c2d265d1d13d3af40fc0c525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TATSUNO=20=E2=80=9CTaz=E2=80=9D=20Yasuhiro?= Date: Mon, 7 Apr 2025 11:13:17 +0900 Subject: [PATCH] [v2][log]: Add generic fern::Dispatch TargetKind to log (#2600) * [v2][log]: Add generic fern::Dispatch TargetKind to log Original: https://github.com/tauri-apps/plugins-workspace/pull/1130/commits/b691382d1ea54733ca837995cfac9f82ea05f168 * Add change file * clippy --------- Co-authored-by: Tony Co-authored-by: venkr --- .changes/fern-dispatch-log-target.md | 6 ++++++ plugins/log/src/lib.rs | 5 +++++ plugins/shell/permissions/schemas/schema.json | 4 ++-- plugins/shell/src/scope.rs | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .changes/fern-dispatch-log-target.md diff --git a/.changes/fern-dispatch-log-target.md b/.changes/fern-dispatch-log-target.md new file mode 100644 index 00000000..e21efc18 --- /dev/null +++ b/.changes/fern-dispatch-log-target.md @@ -0,0 +1,6 @@ +--- +log: minor +log-js: minor +--- + +Adds a new varient `TargetKind::Dispatch` that allows you to construct arbitrary log targets diff --git a/plugins/log/src/lib.rs b/plugins/log/src/lib.rs index 9bf784c7..3c4abdd7 100644 --- a/plugins/log/src/lib.rs +++ b/plugins/log/src/lib.rs @@ -170,6 +170,10 @@ pub enum TargetKind { /// /// This requires the webview to subscribe to log events, via this plugins `attachConsole` function. Webview, + /// Send logs to a [`fern::Dispatch`] + /// + /// You can use this to construct arbitrary log targets. + Dispatch(fern::Dispatch), } /// A log target. @@ -481,6 +485,7 @@ impl Builder { }); }) } + TargetKind::Dispatch(dispatch) => dispatch.into(), }; target_dispatch = target_dispatch.chain(logger); diff --git a/plugins/shell/permissions/schemas/schema.json b/plugins/shell/permissions/schemas/schema.json index f8127c57..9a198981 100644 --- a/plugins/shell/permissions/schemas/schema.json +++ b/plugins/shell/permissions/schemas/schema.json @@ -355,10 +355,10 @@ "markdownDescription": "Denies the stdin_write command without any pre-configured scope." }, { - "description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality with a reasonable\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n", + "description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality with a reasonable\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n\n#### This default permission set includes:\n\n- `allow-open`", "type": "string", "const": "default", - "markdownDescription": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n\n#### This default permission set includes:\n\n- `allow-open`" + "markdownDescription": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality with a reasonable\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n\n#### This default permission set includes:\n\n- `allow-open`" } ] } diff --git a/plugins/shell/src/scope.rs b/plugins/shell/src/scope.rs index 3a450afa..35fdeaff 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -304,7 +304,7 @@ impl ShellScope<'_> { .map(|s| { std::path::PathBuf::from(s) .components() - .last() + .next_back() .unwrap() .as_os_str() .to_string_lossy()