less noise in logs

This commit is contained in:
Nikita Galaiko 2023-09-06 09:33:27 +02:00 committed by GitButler
parent 5f03fcb2df
commit 8bfdc14a46
26 changed files with 182 additions and 224 deletions

View File

@ -5,7 +5,7 @@
[see here](https://tauri.app/v1/guides/getting-started/prerequisites) [see here](https://tauri.app/v1/guides/getting-started/prerequisites)
for the list of software required to build / develope the app. for the list of software required to build / develope the app.
## Setup ### Setup
Then, make sure to install app dependencies: Then, make sure to install app dependencies:
@ -13,9 +13,7 @@ Then, make sure to install app dependencies:
$ pnpm install $ pnpm install
``` ```
## Develop ### Run the app
### Running the app
Now you should be able to run the app in development mode: Now you should be able to run the app in development mode:
@ -23,6 +21,12 @@ Now you should be able to run the app in development mode:
$ pnpm tauri dev $ pnpm tauri dev
``` ```
By default it will not print debug logs to console. If you want debug logs, use `debug` feature:
```bash
$ pnpm tauri dev --features debug
```
### Run Stories ### Run Stories
Stories is our easy way to view our app components. Running the following command will launch in your default browser. Stories is our easy way to view our app components. Running the following command will launch in your default browser.
@ -33,14 +37,14 @@ $ pnpm story:dev
### Lint & format ### Lint & format
Frontend: Javascript:
```bash ```bash
$ pnpm lint $ pnpm lint
$ pnpm format $ pnpm format
``` ```
Backend: Rust:
```bash ```bash
$ cd ./src-tauri $ cd ./src-tauri

View File

@ -66,6 +66,8 @@ resolve-path = "0.1.0"
# by default Tauri runs in production mode # by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = ["custom-protocol"] default = ["custom-protocol"]
# enabled debug logging
debug = []
# this feature enables devtools # this feature enables devtools
devtools = ["tauri/devtools"] devtools = ["tauri/devtools"]
# this feature is used used for production builds where `devPath` points to the filesystem # this feature is used used for production builds where `devPath` points to the filesystem

View File

@ -538,11 +538,11 @@ impl App {
project_repository.git_unstage_files(paths) project_repository.git_unstage_files(paths)
} }
pub fn git_commit(&self, project_id: &str, message: &str, push: bool) -> Result<()> { pub fn git_commit(&self, project_id: &str, message: &str) -> Result<()> {
let project = self.gb_project(project_id)?; let project = self.gb_project(project_id)?;
let project_repository = project_repository::Repository::open(&project) let project_repository = project_repository::Repository::open(&project)
.context("failed to open project repository")?; .context("failed to open project repository")?;
project_repository.git_commit(message, push) project_repository.git_commit(message)
} }
pub fn search(&self, query: &search::Query) -> Result<search::Results> { pub fn search(&self, query: &search::Query) -> Result<search::Results> {

View File

@ -69,7 +69,7 @@ impl Proxy {
return Ok(build_asset_url(&save_to.display().to_string())); return Ok(build_asset_url(&save_to.display().to_string()));
} }
tracing::info!("Downloading image {}", src); tracing::debug!("Downloading image {}", src);
let resp = reqwest::get(src.clone()).await?; let resp = reqwest::get(src.clone()).await?;
if !resp.status().is_success() { if !resp.status().is_success() {

View File

@ -24,7 +24,7 @@ impl<'writer> BookmarksWriter<'writer> {
[bookmark], [bookmark],
)?; )?;
tracing::info!( tracing::debug!(
"{}: wrote bookmark {}", "{}: wrote bookmark {}",
self.repository.project_id, self.repository.project_id,
bookmark.timestamp_ms bookmark.timestamp_ms

View File

@ -31,7 +31,7 @@ impl<'writer> DeltasWriter<'writer> {
self.writer self.writer
.write_string(&format!("session/deltas/{}", path.display()), &raw_deltas)?; .write_string(&format!("session/deltas/{}", path.display()), &raw_deltas)?;
tracing::info!( tracing::debug!(
"{}: wrote deltas for {}", "{}: wrote deltas for {}",
self.repository.project_id, self.repository.project_id,
path.display() path.display()
@ -51,7 +51,7 @@ impl<'writer> DeltasWriter<'writer> {
self.writer self.writer
.write_string(&format!("session/wd/{}", path.display()), contents)?; .write_string(&format!("session/wd/{}", path.display()), contents)?;
tracing::info!( tracing::debug!(
"{}: wrote session wd file {}", "{}: wrote session wd file {}",
self.repository.project_id, self.repository.project_id,
path.display() path.display()

View File

@ -21,7 +21,7 @@ impl Sender {
self.app_handle self.app_handle
.emit_all(&event.name, Some(&event.payload)) .emit_all(&event.name, Some(&event.payload))
.context("emit event")?; .context("emit event")?;
tracing::info!("sent event: {}", event.name); tracing::debug!("sent event: {}", event.name);
Ok(()) Ok(())
} }
} }

View File

@ -165,7 +165,7 @@ impl Repository {
let mut callbacks = git2::RemoteCallbacks::new(); let mut callbacks = git2::RemoteCallbacks::new();
callbacks.push_update_reference(move |refname, message| { callbacks.push_update_reference(move |refname, message| {
tracing::info!( tracing::debug!(
"{}: pulling reference '{}': {:?}", "{}: pulling reference '{}': {:?}",
self.project_id, self.project_id,
refname, refname,
@ -174,7 +174,7 @@ impl Repository {
Result::Ok(()) Result::Ok(())
}); });
callbacks.push_transfer_progress(move |one, two, three| { callbacks.push_transfer_progress(move |one, two, three| {
tracing::info!( tracing::debug!(
"{}: transferred {}/{}/{} objects", "{}: transferred {}/{}/{} objects",
self.project_id, self.project_id,
one, one,
@ -211,7 +211,7 @@ impl Repository {
// Set the remote's callbacks // Set the remote's callbacks
let mut callbacks = git2::RemoteCallbacks::new(); let mut callbacks = git2::RemoteCallbacks::new();
callbacks.push_update_reference(move |refname, message| { callbacks.push_update_reference(move |refname, message| {
tracing::info!( tracing::debug!(
"{}: pushing reference '{}': {:?}", "{}: pushing reference '{}': {:?}",
self.project_id, self.project_id,
refname, refname,
@ -220,7 +220,7 @@ impl Repository {
Result::Ok(()) Result::Ok(())
}); });
callbacks.push_transfer_progress(move |one, two, three| { callbacks.push_transfer_progress(move |one, two, three| {
tracing::info!( tracing::debug!(
"{}: transferred {}/{}/{} objects", "{}: transferred {}/{}/{} objects",
self.project_id, self.project_id,
one, one,
@ -322,8 +322,6 @@ impl Repository {
&self, &self,
project_repository: &project_repository::Repository, project_repository: &project_repository::Repository,
) -> Result<sessions::Session> { ) -> Result<sessions::Session> {
tracing::info!("{}: creating new session", self.project_id);
let now_ms = time::SystemTime::now() let now_ms = time::SystemTime::now()
.duration_since(time::UNIX_EPOCH) .duration_since(time::UNIX_EPOCH)
.unwrap() .unwrap()
@ -355,6 +353,8 @@ impl Repository {
.write(&session) .write(&session)
.context("failed to write session")?; .context("failed to write session")?;
tracing::info!("{}: created new session {}", self.project_id, session.id);
Ok(session) Ok(session)
} }
@ -575,7 +575,7 @@ impl Repository {
let reference = repo.find_reference(&refname); let reference = repo.find_reference(&refname);
match reference { match reference {
Err(git::Error::NotFound(_)) => { Err(git::Error::NotFound(_)) => {
tracing::warn!( tracing::debug!(
"{}: reference {} not found, no migration", "{}: reference {} not found, no migration",
project.id, project.id,
refname refname
@ -621,7 +621,6 @@ impl Repository {
} }
}; };
tracing::warn!("{}: migrated commit {}", project.id, id);
migrated = true migrated = true
} }

View File

@ -48,14 +48,14 @@ pub fn for_key(key: &keys::Key) -> Vec<CredentialsCallback<'_>> {
fn from_keypath(key_path: std::path::PathBuf, passphrase: Option<&str>) -> CredentialsCallback { fn from_keypath(key_path: std::path::PathBuf, passphrase: Option<&str>) -> CredentialsCallback {
Box::new(move |url, _username_from_url, _allowed_types| { Box::new(move |url, _username_from_url, _allowed_types| {
let key_path = key_path.resolve(); let key_path = key_path.resolve();
tracing::info!("authenticating with {} using {}", url, key_path.display()); tracing::debug!("authenticating with {} using {}", url, key_path.display());
git2::Cred::ssh_key("git", None, &key_path, passphrase) git2::Cred::ssh_key("git", None, &key_path, passphrase)
}) })
} }
fn from_key(key: &keys::PrivateKey) -> CredentialsCallback { fn from_key(key: &keys::PrivateKey) -> CredentialsCallback {
Box::new(|url, _username_from_url, _allowed_types| { Box::new(|url, _username_from_url, _allowed_types| {
tracing::info!("authenticating with {} using gitbutler's key", url); tracing::debug!("authenticating with {} using gitbutler's key", url);
git2::Cred::ssh_key_from_memory("git", None, &key.to_string(), None) git2::Cred::ssh_key_from_memory("git", None, &key.to_string(), None)
}) })
} }

View File

@ -5,7 +5,7 @@ use crate::error::Error;
use super::{storage::Storage, PublicKey}; use super::{storage::Storage, PublicKey};
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_public_key", skip(handle))] #[instrument(skip(handle))]
pub async fn get_public_key(handle: tauri::AppHandle) -> Result<PublicKey, Error> { pub async fn get_public_key(handle: tauri::AppHandle) -> Result<PublicKey, Error> {
let controller = Storage::from(&handle); let controller = Storage::from(&handle);
let key = controller.get_or_create()?; let key = controller.get_or_create()?;

View File

@ -11,6 +11,7 @@ pub struct FileLock {
} }
impl FileLock { impl FileLock {
#[instrument(level = "debug")]
pub fn lock(path: PathBuf) -> FileLock { pub fn lock(path: PathBuf) -> FileLock {
let mut options = OpenOptions::new(); let mut options = OpenOptions::new();
options.create_new(true); options.create_new(true);
@ -51,7 +52,6 @@ impl FileLock {
} }
impl Drop for FileLock { impl Drop for FileLock {
#[instrument(skip_all)]
fn drop(&mut self) { fn drop(&mut self) {
std::fs::remove_file(&self.path).expect("failed to delete lock file"); std::fs::remove_file(&self.path).expect("failed to delete lock file");
} }

View File

@ -10,6 +10,7 @@ pub struct FileLock {
} }
impl FileLock { impl FileLock {
#[instrument(level = "debug")]
pub fn lock(path: PathBuf) -> FileLock { pub fn lock(path: PathBuf) -> FileLock {
loop { loop {
// Create lockfile, or open pre-existing one // Create lockfile, or open pre-existing one
@ -33,7 +34,6 @@ impl FileLock {
} }
impl Drop for FileLock { impl Drop for FileLock {
#[instrument(skip_all)]
fn drop(&mut self) { fn drop(&mut self) {
// Removing the file isn't strictly necessary, but reduces confusion. // Removing the file isn't strictly necessary, but reduces confusion.
_ = std::fs::remove_file(&self.path); _ = std::fs::remove_file(&self.path);

View File

@ -18,11 +18,14 @@ pub fn init(app_handle: &AppHandle) {
let format_for_humans = tracing_subscriber::fmt::format() let format_for_humans = tracing_subscriber::fmt::format()
.with_file(true) .with_file(true)
.with_line_number(true) .with_line_number(true)
.with_thread_ids(true)
.with_target(false) .with_target(false)
.compact(); .compact();
let filter_for_humans = LevelFilter::DEBUG; let log_level_filter = if cfg!(feature = "debug") {
LevelFilter::DEBUG
} else {
LevelFilter::INFO
};
let subscriber = tracing_subscriber::registry() let subscriber = tracing_subscriber::registry()
.with( .with(
@ -38,15 +41,15 @@ pub fn init(app_handle: &AppHandle) {
// subscriber that writes spans to stdout // subscriber that writes spans to stdout
tracing_subscriber::fmt::layer() tracing_subscriber::fmt::layer()
.event_format(format_for_humans.clone()) .event_format(format_for_humans.clone())
.with_filter(filter_for_humans), .with_span_events(FmtSpan::CLOSE)
.with_filter(log_level_filter),
) )
.with( .with(
// subscriber that writes spans to a file // subscriber that writes spans to a file
tracing_subscriber::fmt::layer() tracing_subscriber::fmt::layer()
.event_format(format_for_humans) .event_format(format_for_humans)
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
.with_writer(file_writer) .with_writer(file_writer),
.with_filter(filter_for_humans),
); );
set_global_default(subscriber).expect("failed to set subscriber"); set_global_default(subscriber).expect("failed to set subscriber");

View File

@ -13,7 +13,7 @@ use git_butler_tauri::*;
use crate::{error::Error, git, project_repository::activity}; use crate::{error::Error, git, project_repository::activity};
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_project_archive_path", skip(handle))] #[instrument(skip(handle))]
async fn get_project_archive_path( async fn get_project_archive_path(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -29,7 +29,7 @@ async fn get_project_archive_path(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_project_data_archive_path", skip(handle))] #[instrument(skip(handle))]
async fn get_project_data_archive_path( async fn get_project_data_archive_path(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -47,7 +47,7 @@ async fn get_project_data_archive_path(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_logs_archive_path", skip(handle))] #[instrument(skip(handle))]
async fn get_logs_archive_path(handle: tauri::AppHandle) -> Result<String, Error> { async fn get_logs_archive_path(handle: tauri::AppHandle) -> Result<String, Error> {
let zipper = handle.state::<zip::Zipper>(); let zipper = handle.state::<zip::Zipper>();
let zipped_logs = zipper.zip(handle.path_resolver().app_log_dir().unwrap())?; let zipped_logs = zipper.zip(handle.path_resolver().app_log_dir().unwrap())?;
@ -55,7 +55,7 @@ async fn get_logs_archive_path(handle: tauri::AppHandle) -> Result<String, Error
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "search", skip(handle))] #[instrument(skip(handle))]
async fn search( async fn search(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -83,7 +83,7 @@ async fn search(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_sessions", skip(handle))] #[instrument(skip(handle))]
async fn list_sessions( async fn list_sessions(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -97,7 +97,7 @@ async fn list_sessions(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_user", skip(handle))] #[instrument(skip(handle))]
async fn get_user(handle: tauri::AppHandle) -> Result<Option<users::User>, Error> { async fn get_user(handle: tauri::AppHandle) -> Result<Option<users::User>, Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
let proxy = handle.state::<assets::Proxy>(); let proxy = handle.state::<assets::Proxy>();
@ -125,7 +125,7 @@ async fn get_user(handle: tauri::AppHandle) -> Result<Option<users::User>, Error
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "set_user", skip(handle))] #[instrument(skip(handle))]
async fn set_user(handle: tauri::AppHandle, user: users::User) -> Result<(), Error> { async fn set_user(handle: tauri::AppHandle, user: users::User) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
@ -137,7 +137,7 @@ async fn set_user(handle: tauri::AppHandle, user: users::User) -> Result<(), Err
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "delete_user", skip(handle))] #[instrument(skip(handle))]
async fn delete_user(handle: tauri::AppHandle) -> Result<(), Error> { async fn delete_user(handle: tauri::AppHandle) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
@ -149,7 +149,7 @@ async fn delete_user(handle: tauri::AppHandle) -> Result<(), Error> {
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "update_project", skip(handle))] #[instrument(skip(handle))]
async fn update_project( async fn update_project(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project: projects::UpdateRequest, project: projects::UpdateRequest,
@ -167,7 +167,7 @@ async fn update_project(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "add_project", skip(handle))] #[instrument(skip(handle))]
async fn add_project(handle: tauri::AppHandle, path: &str) -> Result<projects::Project, Error> { async fn add_project(handle: tauri::AppHandle, path: &str) -> Result<projects::Project, Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
let project = app.add_project(path)?; let project = app.add_project(path)?;
@ -175,7 +175,7 @@ async fn add_project(handle: tauri::AppHandle, path: &str) -> Result<projects::P
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_project", skip(handle))] #[instrument(skip(handle))]
async fn get_project( async fn get_project(
handle: tauri::AppHandle, handle: tauri::AppHandle,
id: &str, id: &str,
@ -186,7 +186,7 @@ async fn get_project(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_projects", skip(handle))] #[instrument(skip(handle))]
async fn list_projects(handle: tauri::AppHandle) -> Result<Vec<projects::Project>, Error> { async fn list_projects(handle: tauri::AppHandle) -> Result<Vec<projects::Project>, Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
@ -196,7 +196,7 @@ async fn list_projects(handle: tauri::AppHandle) -> Result<Vec<projects::Project
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "delete_project", skip(handle))] #[instrument(skip(handle))]
async fn delete_project(handle: tauri::AppHandle, id: &str) -> Result<(), Error> { async fn delete_project(handle: tauri::AppHandle, id: &str) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
@ -207,7 +207,7 @@ async fn delete_project(handle: tauri::AppHandle, id: &str) -> Result<(), Error>
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_session_files", skip(handle))] #[instrument(skip(handle))]
async fn list_session_files( async fn list_session_files(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -227,7 +227,7 @@ async fn list_session_files(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_deltas", skip(handle))] #[instrument(skip(handle))]
async fn list_deltas( async fn list_deltas(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -247,7 +247,7 @@ async fn list_deltas(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_activity", skip(handle))] #[instrument(skip(handle))]
async fn git_activity( async fn git_activity(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -261,7 +261,7 @@ async fn git_activity(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_status", skip(handle))] #[instrument(skip(handle))]
async fn git_status( async fn git_status(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -274,7 +274,7 @@ async fn git_status(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_wd_diff", skip(handle))] #[instrument(skip(handle))]
async fn git_wd_diff( async fn git_wd_diff(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -288,7 +288,7 @@ async fn git_wd_diff(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_commit_diff", skip(handle))] #[instrument(skip(handle))]
async fn git_commit_diff( async fn git_commit_diff(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -307,7 +307,7 @@ async fn git_commit_diff(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_match_paths", skip(handle))] #[instrument(skip(handle))]
async fn git_match_paths( async fn git_match_paths(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -326,7 +326,7 @@ async fn git_match_paths(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_branches", skip(handle))] #[instrument(skip(handle))]
async fn git_branches( async fn git_branches(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -339,7 +339,7 @@ async fn git_branches(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_remote_branches", skip(handle))] #[instrument(skip(handle))]
async fn git_remote_branches( async fn git_remote_branches(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -355,7 +355,7 @@ async fn git_remote_branches(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_remote_branches_data", skip(handle))] #[instrument(skip(handle))]
async fn git_remote_branches_data( async fn git_remote_branches_data(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -409,7 +409,7 @@ async fn git_remote_branches_data(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_head", skip(handle))] #[instrument(skip(handle))]
async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result<String, Error> { async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result<String, Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
let head = app let head = app
@ -419,7 +419,7 @@ async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result<String,
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_switch_branch", skip(handle))] #[instrument(skip(handle))]
async fn git_switch_branch( async fn git_switch_branch(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -435,7 +435,7 @@ async fn git_switch_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_stage", skip(handle))] #[instrument(skip(handle))]
async fn git_stage( async fn git_stage(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -448,7 +448,7 @@ async fn git_stage(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_unstage", skip(handle))] #[instrument(skip(handle))]
async fn git_unstage( async fn git_unstage(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -461,21 +461,20 @@ async fn git_unstage(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_commit", skip(handle))] #[instrument(skip(handle))]
async fn git_commit( async fn git_commit(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
message: &str, message: &str,
push: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
app.git_commit(project_id, message, push) app.git_commit(project_id, message)
.with_context(|| format!("failed to commit for project {}", project_id))?; .with_context(|| format!("failed to commit for project {}", project_id))?;
Ok(()) Ok(())
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "delete_all_data", skip(handle))] #[instrument(skip(handle))]
async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error> { async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
app.delete_all_data().context("failed to delete all data")?; app.delete_all_data().context("failed to delete all data")?;
@ -483,7 +482,7 @@ async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error> {
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "upsert_bookmark", skip(handle))] #[instrument(skip(handle))]
async fn upsert_bookmark( async fn upsert_bookmark(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: String, project_id: String,
@ -512,7 +511,7 @@ async fn upsert_bookmark(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_bookmarks", skip(handle))] #[instrument(skip(handle))]
async fn list_bookmarks( async fn list_bookmarks(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -526,7 +525,7 @@ async fn list_bookmarks(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "fetch_from_target", skip(handle))] #[instrument(skip(handle))]
async fn fetch_from_target(handle: tauri::AppHandle, project_id: &str) -> Result<(), Error> { async fn fetch_from_target(handle: tauri::AppHandle, project_id: &str) -> Result<(), Error> {
let app = handle.state::<app::App>(); let app = handle.state::<app::App>();
app.fetch_from_target(project_id)?; app.fetch_from_target(project_id)?;
@ -534,7 +533,7 @@ async fn fetch_from_target(handle: tauri::AppHandle, project_id: &str) -> Result
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "mark_resolved", skip(handle))] #[instrument(skip(handle))]
async fn mark_resolved( async fn mark_resolved(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -546,7 +545,7 @@ async fn mark_resolved(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_set_config", skip(handle))] #[instrument(skip(handle))]
async fn git_set_config( async fn git_set_config(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -559,7 +558,7 @@ async fn git_set_config(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_get_config", skip(handle))] #[instrument(skip(handle))]
async fn git_get_config( async fn git_get_config(
handle: tauri::AppHandle, handle: tauri::AppHandle,
project_id: &str, project_id: &str,
@ -571,7 +570,7 @@ async fn git_get_config(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_set_global_config", skip(handle))] #[instrument(skip(handle))]
async fn git_set_global_config( async fn git_set_global_config(
handle: tauri::AppHandle, handle: tauri::AppHandle,
key: &str, key: &str,
@ -583,7 +582,7 @@ async fn git_set_global_config(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "git_get_global_config", skip(handle))] #[instrument(skip(handle))]
async fn git_get_global_config( async fn git_get_global_config(
handle: tauri::AppHandle, handle: tauri::AppHandle,
key: &str, key: &str,
@ -621,7 +620,7 @@ async fn main() {
let item_handle = app_handle.tray_handle().get_item(&id); let item_handle = app_handle.tray_handle().get_item(&id);
match id.as_str() { match id.as_str() {
"quit" => { "quit" => {
tracing::info!("App exited"); tracing::info!("Quitting app");
app_handle.exit(0); app_handle.exit(0);
} }
"toggle" => match get_window(app_handle) { "toggle" => match get_window(app_handle) {
@ -783,29 +782,33 @@ fn get_window(handle: &tauri::AppHandle) -> Option<tauri::Window> {
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
fn create_window(handle: &tauri::AppHandle) -> tauri::Result<tauri::Window> { fn create_window(handle: &tauri::AppHandle) -> tauri::Result<tauri::Window> {
tracing::info!("Creating window");
let app_title = handle.package_info().name.clone(); let app_title = handle.package_info().name.clone();
tauri::WindowBuilder::new(handle, "main", tauri::WindowUrl::App("index.html".into())) let window =
.resizable(true) tauri::WindowBuilder::new(handle, "main", tauri::WindowUrl::App("index.html".into()))
.title(app_title) .resizable(true)
.disable_file_drop_handler() .title(app_title)
.min_inner_size(600.0, 300.0) .disable_file_drop_handler()
.inner_size(800.0, 600.0) .min_inner_size(600.0, 300.0)
.build() .inner_size(800.0, 600.0)
.build()?;
tracing::info!("app window created");
Ok(window)
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
fn create_window(handle: &tauri::AppHandle) -> tauri::Result<tauri::Window> { fn create_window(handle: &tauri::AppHandle) -> tauri::Result<tauri::Window> {
tracing::info!("Creating window"); let window =
tauri::WindowBuilder::new(handle, "main", tauri::WindowUrl::App("index.html".into())) tauri::WindowBuilder::new(handle, "main", tauri::WindowUrl::App("index.html".into()))
.resizable(true) .resizable(true)
.title(handle.package_info().name.clone()) .title(handle.package_info().name.clone())
.min_inner_size(1024.0, 600.0) .min_inner_size(1024.0, 600.0)
.inner_size(1024.0, 600.0) .inner_size(1024.0, 600.0)
.hidden_title(true) .hidden_title(true)
.disable_file_drop_handler() .disable_file_drop_handler()
.title_bar_style(tauri::TitleBarStyle::Overlay) .title_bar_style(tauri::TitleBarStyle::Overlay)
.build() .build()?;
tracing::info!("window created");
Ok(window)
} }
fn set_toggle_menu_hide(handle: &tauri::AppHandle) -> tauri::Result<()> { fn set_toggle_menu_hide(handle: &tauri::AppHandle) -> tauri::Result<()> {

View File

@ -1,4 +1,4 @@
use std::{collections::HashMap, env, path}; use std::{collections::HashMap, path};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use serde::Serialize; use serde::Serialize;
@ -423,27 +423,24 @@ impl<'repository> Repository<'repository> {
let mut remote_callbacks = git2::RemoteCallbacks::new(); let mut remote_callbacks = git2::RemoteCallbacks::new();
remote_callbacks.credentials(credential_callback); remote_callbacks.credentials(credential_callback);
tracing::info!(
"{}: git push {} {}:refs/heads/{}",
self.project.id,
branch.remote(),
head,
branch.branch()
);
match remote.push( match remote.push(
&[&format!("{}:refs/heads/{}", head, branch.branch())], &[&format!("{}:refs/heads/{}", head, branch.branch())],
Some(&mut git2::PushOptions::new().remote_callbacks(remote_callbacks)), Some(&mut git2::PushOptions::new().remote_callbacks(remote_callbacks)),
) { ) {
Ok(()) => { Ok(()) => {
tracing::info!("{}: git push succeeded", self.project.id); tracing::info!(
"{}: git pushed branch {} to {}:refs/heads/{}",
self.project.id,
branch.remote(),
head,
branch.branch()
);
return Ok(()); return Ok(());
} }
Err(git::Error::AuthenticationFailed(e)) => { Err(e) => {
tracing::info!("{}: git push failed: {:#}", self.project.id, e); tracing::error!("{}: git push failed: {:#}", self.project.id, e);
continue; continue;
} }
Err(e) => return Err(Error::Other(e.into())),
} }
} }
@ -461,7 +458,7 @@ impl<'repository> Repository<'repository> {
remote_callbacks.credentials(credential_callback); remote_callbacks.credentials(credential_callback);
remote_callbacks.push_update_reference(|refname, message| { remote_callbacks.push_update_reference(|refname, message| {
if let Some(msg) = message { if let Some(msg) = message {
tracing::info!( tracing::debug!(
"{}: push update reference: {}: {}", "{}: push update reference: {}: {}",
self.project.id, self.project.id,
refname, refname,
@ -471,7 +468,7 @@ impl<'repository> Repository<'repository> {
Ok(()) Ok(())
}); });
remote_callbacks.push_negotiation(|proposals| { remote_callbacks.push_negotiation(|proposals| {
tracing::info!( tracing::debug!(
"{}: push negotiation: {:?}", "{}: push negotiation: {:?}",
self.project.id, self.project.id,
proposals proposals
@ -487,7 +484,7 @@ impl<'repository> Repository<'repository> {
Ok(()) Ok(())
}); });
remote_callbacks.push_transfer_progress(|one, two, three| { remote_callbacks.push_transfer_progress(|one, two, three| {
tracing::info!( tracing::debug!(
"{}: push transfer progress: {} {} {}", "{}: push transfer progress: {} {} {}",
self.project.id, self.project.id,
one, one,
@ -501,11 +498,10 @@ impl<'repository> Repository<'repository> {
fetch_opts.prune(git2::FetchPrune::On); fetch_opts.prune(git2::FetchPrune::On);
let refspec = &format!("+refs/heads/*:refs/remotes/{}/*", remote_name); let refspec = &format!("+refs/heads/*:refs/remotes/{}/*", remote_name);
tracing::info!("{}: git fetch {}", self.project.id, &refspec);
match remote.fetch(&[refspec], Some(&mut fetch_opts)) { match remote.fetch(&[refspec], Some(&mut fetch_opts)) {
Ok(()) => { Ok(()) => {
tracing::info!("{}: fetched {}", self.project.id, remote_name); tracing::info!("{}: git fetched {}", self.project.id, &refspec);
return Ok(()); return Ok(());
} }
Err(e) => { Err(e) => {
@ -518,7 +514,7 @@ impl<'repository> Repository<'repository> {
Err(Error::AuthError) Err(Error::AuthError)
} }
pub fn git_commit(&self, message: &str, push: bool) -> Result<()> { pub fn git_commit(&self, message: &str) -> Result<()> {
let config = self let config = self
.git_repository .git_repository
.config() .config()
@ -538,7 +534,7 @@ impl<'repository> Repository<'repository> {
let tree_id = self.git_repository.index()?.write_tree()?; let tree_id = self.git_repository.index()?.write_tree()?;
let tree = self.git_repository.find_tree(tree_id)?; let tree = self.git_repository.find_tree(tree_id)?;
let parent_commit = self.git_repository.head()?.peel_to_commit()?; let parent_commit = self.git_repository.head()?.peel_to_commit()?;
let commit = self.git_repository.commit( let commit_oid = self.git_repository.commit(
Some("HEAD"), Some("HEAD"),
&signature, &signature,
&signature, &signature,
@ -546,58 +542,13 @@ impl<'repository> Repository<'repository> {
&tree, &tree,
&[&parent_commit], &[&parent_commit],
)?; )?;
tracing::info!("{}: created commit {}", self.project.id, commit);
if push { tracing::info!(
// Get a reference to the current branch "{}: created commit {} with message {}",
let head = self.git_repository.head()?; self.project.id,
let branch = head.name().unwrap(); commit_oid,
message
let branch_remote_name = self.git_repository.branch_upstream_remote(branch)?; );
let branch_name = self.git_repository.branch_upstream_name(branch)?;
tracing::info!(
"{}: pushing {} to {} as {}",
self.project.id,
branch,
branch_remote_name,
branch_name,
);
// Set the remote's callbacks
let mut callbacks = git2::RemoteCallbacks::new();
callbacks.push_update_reference(move |refname, message| {
tracing::info!("pushing reference '{}': {:?}", refname, message);
Ok(())
});
callbacks.push_transfer_progress(move |one, two, three| {
tracing::info!("transferred {}/{}/{} objects", one, two, three);
});
// create ssh key if it's not there
// try to auth with creds from an ssh-agent
callbacks.credentials(|_url, username_from_url, _allowed_types| {
git2::Cred::ssh_key(
username_from_url.unwrap(),
None,
std::path::Path::new(&format!("{}/.ssh/id_ed25519", env::var("HOME").unwrap())),
None,
)
});
let mut push_options = git2::PushOptions::new();
push_options.remote_callbacks(callbacks);
// Push to the remote
let mut remote = self.git_repository.find_remote(&branch_remote_name)?;
remote
.push(&[branch], Some(&mut push_options))
.with_context(|| {
format!("failed to push {:?} to {:?}", branch, branch_remote_name)
})?;
}
Ok(()) Ok(())
} }

View File

@ -112,7 +112,7 @@ pub async fn accept_connection(app: app::App, stream: net::TcpStream) -> Result<
match pty_reader.read(tail) { match pty_reader.read(tail) {
Ok(0) => { Ok(0) => {
// EOF // EOF
tracing::info!("0 bytes read from pty. EOF."); tracing::debug!("0 bytes read from pty. EOF.");
if let Err(e) = ws_sender if let Err(e) = ws_sender
.send(tokio_tungstenite::tungstenite::Message::Close(None)) .send(tokio_tungstenite::tungstenite::Message::Close(None))
.await .await
@ -153,7 +153,7 @@ pub async fn accept_connection(app: app::App, stream: net::TcpStream) -> Result<
} }
} }
tracing::info!("PTY child process killed."); tracing::debug!("PTY child process killed.");
}); });
}); });
@ -180,9 +180,9 @@ pub async fn accept_connection(app: app::App, stream: net::TcpStream) -> Result<
} }
} }
Ok(tokio_tungstenite::tungstenite::Message::Close(_)) => { Ok(tokio_tungstenite::tungstenite::Message::Close(_)) => {
tracing::info!("Closing the websocket connection..."); tracing::debug!("Closing the websocket connection...");
tracing::info!("Killing PTY child process..."); tracing::debug!("Killing PTY child process...");
pty_child_process pty_child_process
.kill() .kill()
.with_context(|| "failed to kill pty child process".to_string())?; .with_context(|| "failed to kill pty child process".to_string())?;

View File

@ -24,7 +24,7 @@ impl<'writer> PtyWriter<'writer> {
[record], [record],
)?; )?;
tracing::info!( tracing::debug!(
"{}: appended pty record to session", "{}: appended pty record to session",
self.repository.project_id self.repository.project_id
); );

View File

@ -243,7 +243,7 @@ impl SearcherInner {
writer.commit()?; writer.commit()?;
self.reader.reload()?; self.reader.reload()?;
tracing::info!( tracing::debug!(
"{}: bookmark {} added to search", "{}: bookmark {} added to search",
bookmark.project_id, bookmark.project_id,
bookmark.timestamp_ms bookmark.timestamp_ms
@ -281,7 +281,7 @@ impl SearcherInner {
self.meta_storage self.meta_storage
.set(repository.get_project_id(), &session.id, index::VERSION)?; .set(repository.get_project_id(), &session.id, index::VERSION)?;
tracing::info!( tracing::debug!(
"{}: session added to search {}", "{}: session added to search {}",
repository.get_project_id(), repository.get_project_id(),
session.id, session.id,

View File

@ -7,7 +7,7 @@ use crate::{error::Error, git};
use super::controller::Controller; use super::controller::Controller;
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "commit_virtual_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn commit_virtual_branch( pub async fn commit_virtual_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -22,7 +22,7 @@ pub async fn commit_virtual_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "list_virtual_branches", skip(handle))] #[instrument(skip(handle))]
pub async fn list_virtual_branches( pub async fn list_virtual_branches(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -35,7 +35,7 @@ pub async fn list_virtual_branches(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "create_virtual_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn create_virtual_branch( pub async fn create_virtual_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -49,7 +49,7 @@ pub async fn create_virtual_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "create_virtual_branch_from_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn create_virtual_branch_from_branch( pub async fn create_virtual_branch_from_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -63,7 +63,7 @@ pub async fn create_virtual_branch_from_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "get_base_branch_data", skip(handle))] #[instrument(skip(handle))]
pub async fn get_base_branch_data( pub async fn get_base_branch_data(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -76,7 +76,7 @@ pub async fn get_base_branch_data(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "set_base_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn set_base_branch( pub async fn set_base_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -93,7 +93,7 @@ pub async fn set_base_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "update_base_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn update_base_branch(handle: AppHandle, project_id: &str) -> Result<(), Error> { pub async fn update_base_branch(handle: AppHandle, project_id: &str) -> Result<(), Error> {
handle handle
.state::<Controller>() .state::<Controller>()
@ -103,7 +103,7 @@ pub async fn update_base_branch(handle: AppHandle, project_id: &str) -> Result<(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "update_virtual_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn update_virtual_branch( pub async fn update_virtual_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -117,7 +117,7 @@ pub async fn update_virtual_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "delete_virtual_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn delete_virtual_branch( pub async fn delete_virtual_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -131,7 +131,7 @@ pub async fn delete_virtual_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "apply_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn apply_branch(handle: AppHandle, project_id: &str, branch: &str) -> Result<(), Error> { pub async fn apply_branch(handle: AppHandle, project_id: &str, branch: &str) -> Result<(), Error> {
handle handle
.state::<Controller>() .state::<Controller>()
@ -141,7 +141,7 @@ pub async fn apply_branch(handle: AppHandle, project_id: &str, branch: &str) ->
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "unapply_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn unapply_branch( pub async fn unapply_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,
@ -155,7 +155,7 @@ pub async fn unapply_branch(
} }
#[tauri::command(async)] #[tauri::command(async)]
#[instrument(name = "push_virtual_branch", skip(handle))] #[instrument(skip(handle))]
pub async fn push_virtual_branch( pub async fn push_virtual_branch(
handle: AppHandle, handle: AppHandle,
project_id: &str, project_id: &str,

View File

@ -36,25 +36,31 @@ impl Dispatcher {
let (notify_tx, mut notify_rx) = channel(1); let (notify_tx, mut notify_rx) = channel(1);
let mut watcher = RecommendedWatcher::new( let mut watcher = RecommendedWatcher::new(
move |res: notify::Result<notify::Event>| match res { {
Ok(event) => { let project_id = project_id.to_string();
if !is_interesting_kind(&event.kind) { move |res: notify::Result<notify::Event>| match res {
return; Ok(event) => {
} if !is_interesting_kind(&event.kind) {
for path in event return;
.paths }
.into_iter() for path in event
.filter(|file| is_interesting_file(&repo, file)) .paths
{ .into_iter()
block_on(async { .filter(|file| is_interesting_file(&repo, file))
tracing::warn!("detected file change event: {}", path.display()); {
if let Err(error) = notify_tx.send(path).await { block_on(async {
tracing::error!("failed to send file change event: {:#}", error); tracing::info!("{}: file change detected: {}", project_id, path.display());
} if let Err(error) = notify_tx.send(path).await {
}); tracing::error!(
"failed to send file change event: {:#}",
error
);
}
});
}
} }
Err(error) => tracing::error!("file watcher error: {:#}", error),
} }
Err(error) => tracing::error!("file watcher error: {:#}", error),
}, },
Config::default(), Config::default(),
)?; )?;
@ -64,7 +70,7 @@ impl Dispatcher {
.with_context(|| format!("failed to watch project path: {}", path.display()))?; .with_context(|| format!("failed to watch project path: {}", path.display()))?;
self.watcher.lock().unwrap().replace(watcher); self.watcher.lock().unwrap().replace(watcher);
tracing::info!("{}: file watcher started", project_id); tracing::debug!("{}: file watcher started", project_id);
let (tx, rx) = channel(1); let (tx, rx) = channel(1);
let project_id = project_id.to_string(); let project_id = project_id.to_string();
@ -104,7 +110,7 @@ impl Dispatcher {
} }
} }
} }
tracing::info!("{}: file watcher stopped", project_id); tracing::debug!("{}: file watcher stopped", project_id);
} }
})?; })?;

View File

@ -80,7 +80,7 @@ impl Dispatcher {
} }
} }
} }
tracing::info!("{}: dispatcher stopped", project_id); tracing::debug!("{}: dispatcher stopped", project_id);
})?; })?;
Ok(rx) Ok(rx)

View File

@ -39,7 +39,7 @@ impl Dispatcher {
.spawn({ .spawn({
let project_id = project_id.to_string(); let project_id = project_id.to_string();
async move { async move {
tracing::info!("{}: ticker started", project_id); tracing::debug!("{}: ticker started", project_id);
loop { loop {
ticker.tick().await; ticker.tick().await;
if self.cancellation_token.is_cancelled() { if self.cancellation_token.is_cancelled() {
@ -55,7 +55,7 @@ impl Dispatcher {
tracing::error!("{}: failed to send tick: {}", project_id, e); tracing::error!("{}: failed to send tick: {}", project_id, e);
} }
} }
tracing::info!("{}: ticker stopped", project_id); tracing::debug!("{}: ticker stopped", project_id);
} }
})?; })?;

View File

@ -39,20 +39,13 @@ impl Handler {
.with_context(|| "failed to open project repository for project")?; .with_context(|| "failed to open project repository for project")?;
match path.as_ref().to_str().unwrap() { match path.as_ref().to_str().unwrap() {
"FETCH_HEAD" => { "FETCH_HEAD" => Ok(vec![events::Event::Emit(app_events::Event::git_fetch(
tracing::info!("{}: git fetch", project.id); &project.id,
Ok(vec![events::Event::Emit(app_events::Event::git_fetch( ))]),
&project.id, "logs/HEAD" => Ok(vec![events::Event::Emit(app_events::Event::git_activity(
))]) &project.id,
} ))]),
"logs/HEAD" => {
tracing::info!("{}: git activity", project.id);
Ok(vec![events::Event::Emit(app_events::Event::git_activity(
&project.id,
))])
}
"HEAD" => { "HEAD" => {
tracing::info!("{}: git head changed", project.id);
let head_ref = project_repository.get_head()?; let head_ref = project_repository.get_head()?;
if let Some(head) = head_ref.name() { if let Some(head) = head_ref.name() {
Ok(vec![events::Event::Emit(app_events::Event::git_head( Ok(vec![events::Event::Emit(app_events::Event::git_head(
@ -63,12 +56,9 @@ impl Handler {
Ok(vec![]) Ok(vec![])
} }
} }
"index" => { "index" => Ok(vec![events::Event::Emit(app_events::Event::git_index(
tracing::info!("{}: git index changed", project.id); &project.id,
Ok(vec![events::Event::Emit(app_events::Event::git_index( ))]),
&project.id,
))])
}
_ => Ok(vec![]), _ => Ok(vec![]),
} }
} }

View File

@ -47,7 +47,7 @@ impl TryFrom<&AppHandle> for Handler {
} }
impl Handler { impl Handler {
#[instrument(name = "handle", skip(self), fields(event = %event))] #[instrument(skip(self), fields(event = %event), level = "debug")]
pub fn handle(&self, event: &events::Event) -> Result<Vec<events::Event>> { pub fn handle(&self, event: &events::Event) -> Result<Vec<events::Event>> {
match event { match event {
events::Event::ProjectFileChange(project_id, path) => self events::Event::ProjectFileChange(project_id, path) => self

View File

@ -50,7 +50,7 @@ impl Watchers {
if let Err(e) = c_watcher.run(&project_path, &project_id).await { if let Err(e) = c_watcher.run(&project_path, &project_id).await {
tracing::error!("watcher error: {:#}", e); tracing::error!("watcher error: {:#}", e);
} }
tracing::info!("watcher stopped"); tracing::debug!("watcher stopped");
})?; })?;
self.watchers self.watchers
@ -188,7 +188,7 @@ impl WatcherInner {
e e
); );
} else { } else {
tracing::info!( tracing::debug!(
"{}: sent response event: {}", "{}: sent response event: {}",
project_id, project_id,
event event

View File

@ -2,7 +2,7 @@ export type { Activity } from './activities';
import { invoke } from '$lib/ipc'; import { invoke } from '$lib/ipc';
export function commit(params: { projectId: string; message: string; push: boolean }) { export function commit(params: { projectId: string; message: string }) {
return invoke<boolean>('git_commit', params); return invoke<boolean>('git_commit', params);
} }