Expand description
§logbook
Core library for the logbook
CLI. The binary in src/main.rs is a thin wrapper around the pure
functions and types defined here, which lets the integration suite
exercise the parser, error paths, and atomic-write logic directly
without shelling out.
Most consumers should use the CLI; this library is exposed so that tooling (test suites, downstream integrations, alternative front-ends like a web viewer) can manipulate logbook files without re-implementing the format.
§Example: append an entry to a file
use logbook::{atomic_append, init_file, render_entry_block, RenderInput, today};
use std::path::Path;
let path = Path::new("logbook.md");
init_file(path)?;
let date = today();
let block = render_entry_block(&RenderInput {
date: &date,
title: "switched to websockets",
why: "polling was hammering the API",
rejected: Some("redis pub/sub (overkill)"),
risk: None,
tags: &["refactor".to_string(), "perf".to_string()],
});
atomic_append(path, &block)?;§Example: parse an existing file
use logbook::parse_entries;
let text = "# logbook\n\n## 2026-05-16 — t\n**why:** w\n**tags:** refactor, perf\n";
let entries = parse_entries(text);
assert_eq!(entries.len(), 1);
assert_eq!(entries[0].date.as_deref(), Some("2026-05-16"));
assert_eq!(entries[0].tags, vec!["refactor", "perf"]);Re-exports§
pub use error::Error;pub use error::Result;pub use parse::parse_entries;pub use parse::Entry;pub use store::atomic_append;pub use store::init_file;pub use store::read_text;pub use store::render_entry_block;pub use store::RenderInput;
Modules§
- error
- Error types for the
logbooklibrary. - parse
- Parser for the logbook markdown format.
- store
- File I/O for the logbook.
Constants§
- DEFAULT_
LOGBOOK_ FILE - Default filename used when
ENV_VARis not set:logbook.md. - ENV_VAR
- Environment variable that overrides the default logbook path.
- HEADER
- Markdown header written to a freshly-initialized logbook file.
Functions§
- is_
date_ shaped - Cheap shape check for date arguments.
- logbook_
path - Resolve the logbook file path.
- today
- Today’s date in
YYYY-MM-DDformat, local time.