Skip to content

Commit

Permalink
feat: Display all logs in settings (#327)
Browse files Browse the repository at this point in the history
* fix number input

* New log watcher

* fix inifnite loop, don't parse empty lines

* global log watcher 1

* cleanup

* fix

* fix

---------

Co-authored-by: Adam Ciarciński <[email protected]>
  • Loading branch information
t-aleksander and moubctez authored Oct 9, 2024
1 parent 71b76ce commit 49962c1
Show file tree
Hide file tree
Showing 17 changed files with 881 additions and 61 deletions.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local-ip-address = "0.6"
log = "0.4"
prost = "0.13"
rand = "0.8"
regex = "1.11"
reqwest = { version = "0.12", features = ["json"] }
rust-ini = "0.21"
serde_json = "1.0"
Expand Down
13 changes: 9 additions & 4 deletions src-tauri/src/bin/defguard-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ use defguard_client::{
__cmd__disconnect, __cmd__get_latest_app_version, __cmd__get_settings, __cmd__last_connection,
__cmd__location_interface_details, __cmd__location_stats, __cmd__open_link,
__cmd__parse_tunnel_config, __cmd__save_device_config, __cmd__save_tunnel,
__cmd__tunnel_details, __cmd__update_instance, __cmd__update_location_routing,
__cmd__update_settings, __cmd__update_tunnel,
__cmd__start_global_logwatcher, __cmd__stop_global_logwatcher, __cmd__tunnel_details,
__cmd__update_instance, __cmd__update_location_routing, __cmd__update_settings,
__cmd__update_tunnel,
appstate::AppState,
commands::{
active_connection, all_connections, all_instances, all_locations, all_tunnels, connect,
delete_instance, delete_tunnel, disconnect, get_latest_app_version, get_settings,
last_connection, location_interface_details, location_stats, open_link,
parse_tunnel_config, save_device_config, save_tunnel, tunnel_details, update_instance,
update_location_routing, update_settings, update_tunnel,
parse_tunnel_config, save_device_config, save_tunnel, start_global_logwatcher,
stop_global_logwatcher, tunnel_details, update_instance, update_location_routing,
update_settings, update_tunnel,
},
database::{self, models::settings::Settings},
enterprise::periodic::config::poll_config,
Expand All @@ -35,6 +37,7 @@ use log::{Level, LevelFilter};
use tauri::{api::process, Env};
use tauri::{Builder, Manager, RunEvent, State, SystemTray, WindowEvent};
use tauri_plugin_log::LogTarget;
use tracing;

#[derive(Clone, serde::Serialize)]
struct Payload {
Expand Down Expand Up @@ -102,6 +105,8 @@ async fn main() {
update_tunnel,
delete_tunnel,
get_latest_app_version,
start_global_logwatcher,
stop_global_logwatcher
])
.on_window_event(|event| match event.event() {
WindowEvent::CloseRequested { api, .. } => {
Expand Down
20 changes: 19 additions & 1 deletion src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ use crate::{
enterprise::periodic::config::poll_instance,
error::Error,
events::{CONNECTION_CHANGED, INSTANCE_UPDATE, LOCATION_UPDATE},
log_watcher::{
global_log_watcher::{spawn_global_log_watcher_task, stop_global_log_watcher_task},
service_log_watcher::stop_log_watcher_task,
},
proto::{DeviceConfig, DeviceConfigResponse},
service::{log_watcher::stop_log_watcher_task, proto::RemoveInterfaceRequest},
service::proto::RemoveInterfaceRequest,
tray::{configure_tray_icon, reload_tray_menu},
utils::{
disconnect_interface, get_location_interface_details, get_tunnel_interface_details,
Expand Down Expand Up @@ -67,6 +71,20 @@ pub async fn connect(
Ok(())
}

#[tauri::command(async)]
pub async fn start_global_logwatcher(handle: AppHandle) -> Result<(), Error> {
let result = spawn_global_log_watcher_task(&handle, tracing::Level::DEBUG).await;
if let Err(err) = result {
error!("Error while spawning the global log watcher task: {}", err)
}
Ok(())
}

#[tauri::command(async)]
pub async fn stop_global_logwatcher(handle: AppHandle) -> Result<(), Error> {
stop_global_log_watcher_task(&handle)
}

#[tauri::command]
pub async fn disconnect(
location_id: Id,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod database;
pub mod enterprise;
pub mod error;
pub mod events;
pub mod log_watcher;
pub mod periodic;
pub mod service;
pub mod tray;
Expand Down
Loading

0 comments on commit 49962c1

Please sign in to comment.