Skip to content

Commit

Permalink
fix: Limit logging to Vox
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoh committed Sep 11, 2024
1 parent 5f3403c commit 6c20656
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ required-features = ["cli"]

[dependencies]
chrono = { version = "0.4.38", features = ["serde", "unstable-locales"] }
clap = { version = "4.5.6", features = ["derive", "cargo"], optional = true }
comrak = { version = "0.24.1", features = ["syntect", "shortcodes"], default-features = false }
clap = { version = "4.5.17", features = ["derive", "cargo"], optional = true }
comrak = { version = "0.28.0", features = ["syntect", "shortcodes"], default-features = false }
daggy = { version = "0.8.0", features = ["stable_dag"] }
toml = "0.8.14"
liquid = "0.26.6"
liquid-core = "0.26.6"
liquid-lib = { version = "0.26.6", features = ["all", "stdlib", "jekyll", "shopify", "extra"] }
serde = "1.0.203"
toml = "0.8.19"
liquid = "0.26.9"
liquid-core = "0.26.9"
liquid-lib = { version = "0.26.9", features = ["all", "stdlib", "jekyll", "shopify", "extra"] }
serde = "1.0.210"
sys-locale = "0.3.1"
latex2mathml = "0.2.3"
ahash = { version = "0.8.11", features = ["std", "serde", "runtime-rng"] }
mimalloc = { version = "0.1.42", optional = true }
mimalloc = { version = "0.1.43", optional = true }
ticky = { version = "1.0.2", optional = true }
miette = { version = "7.2.0", features = ["fancy", "syntect-highlighter"] }
thiserror = "1.0.61"
thiserror = "1.0.63"
glob = "0.3.1"
tokio = { version = "1.38.0", features = ["full"], optional = true }
tokio = { version = "1.40.0", features = ["full"], optional = true }
futures = "0.3.30"
tracing-subscriber = { version = "0.3.18", optional = true, features = ["env-filter"]}
tracing = "0.1.40"
notify-debouncer-full = { version = "0.3.1", default-features = false, optional = true }
actix-files = { version = "0.6.5", optional = true }
actix-web = { version = "4.6.0", optional = true }
actix-files = { version = "0.6.6", optional = true }
actix-web = { version = "4.9.0", optional = true }
layout-rs = "0.1.2"
html-escape = "0.2.13"
syntect = "5.2.0"
Expand Down
25 changes: 10 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ static GLOBAL: MiMalloc = MiMalloc;
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
/// The level of log output; warnings, information, debugging messages, and trace logs.
#[arg(short, long, action = clap::ArgAction::Count, default_value_t = 2, global = true)]
verbosity: u8,
}
#[derive(Subcommand)]
enum Commands {
Expand All @@ -49,9 +52,6 @@ enum Commands {
/// Watch for changes.
#[arg(short, long, default_value_t = false)]
watch: bool,
/// The level of log output; warnings, information, debugging messages, and trace logs.
#[arg(short, long, action = clap::ArgAction::Count, default_value_t = 0)]
verbosity: u8,
/// Visualise the DAG.
#[arg(short = 'd', long, default_value_t = false)]
visualise_dag: bool,
Expand All @@ -70,9 +70,6 @@ enum Commands {
/// The port to serve the site on.
#[arg(short, long, default_value_t = 80)]
port: u16,
/// The level of log output; warnings, information, debugging messages, and trace logs.
#[arg(short, long, action = clap::ArgAction::Count, default_value_t = 0)]
verbosity: u8,
/// Visualise the DAG.
#[arg(short = 'd', long, default_value_t = false)]
visualise_dag: bool,
Expand All @@ -84,19 +81,19 @@ enum Commands {

#[tokio::main(flavor = "multi_thread")]
async fn main() -> miette::Result<()> {
miette::set_panic_hook();
let cli = Cli::parse();
match cli.command {
Some(Commands::Build {
path,
watch,
verbosity,
visualise_dag,
generate_syntax_css,
}) => {
if let Some(path) = path {
std::env::set_current_dir(path).into_diagnostic()?;
}
let verbosity_level = match verbosity {
let verbosity_level = match cli.verbosity {
0 => Level::ERROR,
1 => Level::WARN,
2 => Level::INFO,
Expand All @@ -105,12 +102,11 @@ async fn main() -> miette::Result<()> {
_ => Level::TRACE,
};
let mut subscriber_builder = tracing_subscriber::fmt()
.with_env_filter("vox")
.with_env_filter(format!("vox={}", verbosity_level))
.pretty()
.with_max_level(verbosity_level)
.with_file(false)
.with_line_number(false);
if verbosity >= 3 {
if cli.verbosity >= 3 {
subscriber_builder = subscriber_builder
.with_thread_ids(true)
.with_thread_names(true)
Expand Down Expand Up @@ -143,14 +139,13 @@ async fn main() -> miette::Result<()> {
path,
watch,
port,
verbosity,
visualise_dag,
generate_syntax_css,
}) => {
if let Some(path) = path {
std::env::set_current_dir(path).into_diagnostic()?;
}
let verbosity_level = match verbosity {
let verbosity_level = match cli.verbosity {
0 => Level::ERROR,
1 => Level::WARN,
2 => Level::INFO,
Expand All @@ -159,11 +154,11 @@ async fn main() -> miette::Result<()> {
_ => Level::TRACE,
};
let mut subscriber_builder = tracing_subscriber::fmt()
.with_env_filter(format!("vox={}", verbosity_level))
.pretty()
.with_max_level(verbosity_level)
.with_file(false)
.with_line_number(false);
if verbosity >= 3 {
if cli.verbosity >= 3 {
subscriber_builder = subscriber_builder
.with_thread_ids(true)
.with_thread_names(true)
Expand Down
11 changes: 11 additions & 0 deletions src/markdown_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ pub fn render_markdown(text_to_render: String) -> String {
options.extension.math_dollars = true;
options.extension.math_code = true;
options.extension.shortcodes = true;
options.extension.wikilinks_title_after_pipe = true;
options.extension.wikilinks_title_before_pipe = false;
options.extension.underline = true;
options.extension.spoiler = true;
options.extension.greentext = false;
options.parse.smart = true;
options.parse.default_info_string = None;
options.parse.relaxed_tasklist_matching = true;
Expand All @@ -47,6 +52,12 @@ pub fn render_markdown(text_to_render: String) -> String {
options.render.escape = false;
options.render.list_style = ListStyleType::Dash;
options.render.sourcepos = false;
options.render.escaped_char_spans = false;
options.render.ignore_setext = false;
options.render.ignore_empty_links = true;
options.render.gfm_quirks = false;
options.render.prefer_fenced = false;
options.render.figure_with_caption = false;
let mut plugins = ComrakPlugins::default();
let syntax_highlighting_adapter = SyntectAdapter::new(None);
plugins.render.codefence_syntax_highlighter = Some(&syntax_highlighting_adapter);
Expand Down

0 comments on commit 6c20656

Please sign in to comment.