Skip to content

Commit 7d8ca04

Browse files
committed
Add proper logging
It's getting very annoynig commenting and uncommenting printlines
1 parent 0d88568 commit 7d8ca04

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ default-run = "advent-of-code"
1111
[dependencies]
1212
ansi_term = "0.12.1"
1313
clap = { version = "4.0.29", features = ["cargo", "derive", "env"] }
14+
env_logger = "0.11.8"
1415
hex = "0.4.3"
1516
humantime = "2.1.0"
1617
inventory = "0.3.2"
1718
itertools = "0.14.0"
1819
lazy_static = "1.4.0"
20+
log = "0.4.28"
1921
md-5 = "0.10.6"
2022
num = "0.4.1"
2123
regex = "1.7.0"

src/aoc/y2025/day01.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ pub fn part_1(data: crate::DataIn) -> crate::AoCResult<String> {
9898
let mut dial: Dial = Default::default();
9999
for line in data {
100100
let instruction = line.parse()?;
101-
// println!("{dial}\n{instruction}");
101+
log::debug!("{dial}");
102+
log::debug!("-> {instruction}");
102103
dial.rotate(instruction);
103104
if dial.0 == 0 {
104105
ret += 1;
105106
}
106107
}
107-
// println!("{dial}");
108+
log::info!("{dial}");
108109
Ok(ret.to_string())
109110
}
110111

src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ use std::collections::HashMap;
1111
use std::process::ExitCode;
1212
use std::time::Instant;
1313

14-
use advent_of_code::{AoCData, AoCDay, AoCError, AoCResult};
14+
use env_logger::Builder;
1515
use itertools::Itertools;
16+
use log::LevelFilter;
17+
18+
use advent_of_code::{AoCData, AoCDay, AoCError, AoCResult};
1619

1720
type DayMap = HashMap<&'static str, HashMap<&'static str, &'static AoCDay>>;
1821

@@ -101,6 +104,12 @@ fn main_wrapped() -> AoCResult<()> {
101104
}
102105

103106
fn main() -> ExitCode {
107+
Builder::new()
108+
.filter_level(LevelFilter::Info)
109+
.format_target(false)
110+
.format_timestamp(None)
111+
.parse_default_env()
112+
.init();
104113
match main_wrapped() {
105114
Ok(_) => ExitCode::SUCCESS,
106115
Err(err) => {

0 commit comments

Comments
 (0)