Skip to content

Commit 8a64b5e

Browse files
authored
Merge pull request #95 from emilioziniades/configure-logging
fix: log to stdout using tracing subscriber.
2 parents bb23016 + 2e3ddab commit 8a64b5e

File tree

3 files changed

+112
-3
lines changed

3 files changed

+112
-3
lines changed

Cargo.lock

Lines changed: 99 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ serde_json = "1.0.108"
1818
anstream = "0.6.4"
1919
cooklang-fs = "0.9.0"
2020
tracing = "0.1.40"
21+
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
2122
serde = "1.0.190"
2223
tabular = "0.2.0"
2324
directories = "5.0.1"

src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const UTF8_PATH_PANIC: &str = "cook only supports UTF-8 paths.";
5555
const AUTO_AISLE: &str = "aisle.conf";
5656

5757
pub fn main() -> Result<()> {
58+
configure_logging();
59+
5860
let args = CliArgs::parse();
5961

6062
let ctx = configure_context()?;
@@ -115,6 +117,16 @@ fn configure_parser() -> Result<CooklangParser> {
115117
Ok(CooklangParser::new(extensions, converter))
116118
}
117119

120+
fn configure_logging() -> () {
121+
tracing_subscriber::fmt()
122+
// Log this crate at level `trace`, but all other crates at level `info`.
123+
.with_env_filter("info,cooklang=info,cook=trace")
124+
.without_time()
125+
.with_target(false)
126+
.compact()
127+
.init();
128+
}
129+
118130
pub fn resolve_path(base_path: &Utf8Path, path: &Path) -> Utf8PathBuf {
119131
let path = Utf8Path::from_path(path).expect(UTF8_PATH_PANIC);
120132
if path.is_absolute() {

0 commit comments

Comments
 (0)