mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 01:22:12 +03:00
Add a flag to allow performance logging: GITBUTLER_PERFORMANCE_LOG
```` GITBUTLER_PERFORMANCE_LOG=1 LOG_LEVEL=debug pnpm tauri dev ```` Additionally, some noise was removed by turning a warning into a trace.
This commit is contained in:
parent
7e0878a14f
commit
fc63929da3
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2565,6 +2565,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-forest",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
|
@ -132,6 +132,12 @@ The app writes logs into:
|
||||
1. `stdout` in development mode
|
||||
2. The Tauri [logs](https://tauri.app/v1/api/js/path/#platform-specific) directory
|
||||
|
||||
One can get performance log when launching the application locally as follows:
|
||||
|
||||
```bash
|
||||
GITBUTLER_PERFORMANCE_LOG=1 LOG_LEVEL=debug pnpm tauri dev
|
||||
```
|
||||
|
||||
### Tokio
|
||||
|
||||
We are also collecting tokio's runtime tracing information that could be viewed using [tokio-console](https://github.com/tokio-rs/console#tokio-console-prototypes):
|
||||
|
@ -77,14 +77,19 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
mod trace {
|
||||
use tracing::metadata::LevelFilter;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::Layer;
|
||||
|
||||
pub fn init() -> anyhow::Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_forest::ForestLayer::from(
|
||||
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stderr),
|
||||
))
|
||||
.with(
|
||||
tracing_forest::ForestLayer::from(
|
||||
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stderr),
|
||||
)
|
||||
.with_filter(LevelFilter::DEBUG),
|
||||
)
|
||||
.init();
|
||||
Ok(())
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl CommandContext {
|
||||
Ok(false) => true,
|
||||
Ok(true) => false,
|
||||
Err(err) => {
|
||||
tracing::warn!(
|
||||
tracing::trace!(
|
||||
"failed to get gitbutler.didSetPrune for repository at {}; cannot disable gc: {}",
|
||||
project.path.display(),
|
||||
err
|
||||
|
@ -47,6 +47,7 @@ tokio = { workspace = true, features = ["rt-multi-thread", "parking_lot"] }
|
||||
tracing.workspace = true
|
||||
tracing-appender = "0.2.3"
|
||||
tracing-subscriber.workspace = true
|
||||
tracing-forest = { version = "0.1.6" }
|
||||
gitbutler-watcher.workspace = true
|
||||
gitbutler-branch-actions.workspace = true
|
||||
gitbutler-oplog.workspace = true
|
||||
|
@ -5,7 +5,7 @@ use tracing::{instrument, metadata::LevelFilter, subscriber::set_global_default}
|
||||
use tracing_appender::rolling::{RollingFileAppender, Rotation};
|
||||
use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, Layer};
|
||||
|
||||
pub fn init(app_handle: &AppHandle) {
|
||||
pub fn init(app_handle: &AppHandle, performance_logging: bool) {
|
||||
let logs_dir = app_handle
|
||||
.path_resolver()
|
||||
.app_log_dir()
|
||||
@ -53,25 +53,37 @@ pub fn init(app_handle: &AppHandle) {
|
||||
.recording_path(logs_dir.join("tokio-console"))
|
||||
.spawn(),
|
||||
)
|
||||
.with(
|
||||
// subscriber that writes spans to stdout
|
||||
tracing_subscriber::fmt::layer()
|
||||
.event_format(format_for_humans.clone())
|
||||
.with_ansi(use_colors_in_logs)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_filter(log_level_filter),
|
||||
)
|
||||
.with(
|
||||
// subscriber that writes spans to a file
|
||||
tracing_subscriber::fmt::layer()
|
||||
.event_format(format_for_humans)
|
||||
.event_format(format_for_humans.clone())
|
||||
.with_ansi(false)
|
||||
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
||||
.with_writer(file_writer)
|
||||
.with_filter(log_level_filter),
|
||||
);
|
||||
|
||||
set_global_default(subscriber).expect("failed to set subscriber");
|
||||
if performance_logging {
|
||||
set_global_default(
|
||||
subscriber.with(
|
||||
tracing_forest::ForestLayer::from(
|
||||
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stdout),
|
||||
)
|
||||
.with_filter(log_level_filter),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
set_global_default(
|
||||
subscriber.with(
|
||||
// subscriber that writes spans to stdout
|
||||
tracing_subscriber::fmt::layer()
|
||||
.event_format(format_for_humans)
|
||||
.with_ansi(use_colors_in_logs)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_filter(log_level_filter),
|
||||
),
|
||||
)
|
||||
}
|
||||
.expect("failed to set subscriber");
|
||||
}
|
||||
|
||||
fn get_server_addr(app_handle: &AppHandle) -> (Ipv4Addr, u16) {
|
||||
|
@ -20,6 +20,7 @@ use tauri::{generate_context, Manager};
|
||||
use tauri_plugin_log::LogTarget;
|
||||
|
||||
fn main() {
|
||||
let performance_logging = std::env::var_os("GITBUTLER_PERFORMANCE_LOG").is_some();
|
||||
gitbutler_project::configure_git2();
|
||||
let tauri_context = generate_context!();
|
||||
gitbutler_secret::secret::set_application_namespace(
|
||||
@ -60,7 +61,7 @@ fn main() {
|
||||
|
||||
let app_handle = tauri_app.handle();
|
||||
|
||||
logs::init(&app_handle);
|
||||
logs::init(&app_handle, performance_logging);
|
||||
|
||||
// On MacOS, in dev mode with debug assertions, we encounter popups each time
|
||||
// the binary is rebuilt. To counter that, use a git-credential based implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user