Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/bin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{Result, anyhow};
use backtrace::Backtrace;
use flexi_logger::{LogSpecification, Logger};
use flexi_logger::{FileSpec, LogSpecification, Logger};
use std::ffi::OsString;
use std::panic::{self, PanicHookInfo};
use std::sync::Arc;
Expand Down Expand Up @@ -55,12 +55,17 @@ where
//
// FIXME: should be initialize before options, but options prints completion that should be
// done before terminal switched to raw mode.
let logger = Logger::try_with_env_or_str(
let mut logger = Logger::try_with_env_or_str(
"trace,cursive=info,clickhouse_rs=info,skim=info,tuikit=info,hyper=info,rustls=info",
)?
.log_to_writer(cursive_flexi_logger_view::cursive_flexi_logger(&siv))
.format(flexi_logger::colored_with_thread)
.start()?;
)?;
if let Some(log) = &options.service.log {
logger = logger.log_to_file(FileSpec::try_from(log)?);
} else {
logger = logger.log_to_writer(cursive_flexi_logger_view::cursive_flexi_logger(&siv));
}
let logger = logger
.format(flexi_logger::colored_with_thread)
.start()?;

// FIXME: should be initialized before cursive, otherwise on error it clears the terminal.
let context: ContextArc = Context::new(options, clickhouse, siv.cb_sink().clone()).await?;
Expand Down
5 changes: 4 additions & 1 deletion src/interpreter/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct ChDigOptions {
#[command(subcommand)]
pub start_view: Option<ChDigViews>,
#[command(flatten)]
service: ServiceOptions,
pub service: ServiceOptions,
}

#[derive(Args, Clone, Default)]
Expand Down Expand Up @@ -217,6 +217,9 @@ pub struct ViewOptions {
pub struct ServiceOptions {
#[arg(long, value_enum)]
completion: Option<Shell>,
#[arg(long)]
/// Log (for debugging chdig itself)
pub log: Option<String>,
}

fn read_yaml_clickhouse_client_config(path: &str) -> Result<ClickHouseClientConfig> {
Expand Down
6 changes: 3 additions & 3 deletions src/view/log_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl LogViewBase {
self.update_content = false;
}

fn content_required_size(&mut self, mut req: Vec2) -> Vec2 {
fn inner_required_size(&mut self, mut req: Vec2) -> Vec2 {
self.screen_size_without_wrap = req;

let rows = self.rows.as_ref().map_or(0, |r| r.len());
Expand Down Expand Up @@ -424,7 +424,7 @@ impl View for LogViewBase {
size.saturating_sub((0, 0)),
self.needs_relayout,
Self::layout_content,
Self::content_required_size,
Self::inner_required_size,
);

if let Some(matched_row) = self.matched_row {
Expand All @@ -441,7 +441,7 @@ impl ViewWrapper for LogView {
.inner_view
.get_inner_mut()
.get_mut()
.content_required_size(req);
.inner_required_size(req);
// For scrollbars
req.x += 1;
req.y += 1;
Expand Down
Loading