alembic-log

Crates.ioalembic-log
lib.rsalembic-log
version0.1.3
created_at2025-08-07 01:38:28.997161+00
updated_at2025-09-14 17:20:48.011139+00
descriptionA Rust crate that lets you log once, send anywhere.
homepagehttps://github.com/mnowzari/alembic
repositoryhttps://github.com/mnowzari/alembic
max_upload_size
id1784587
size35,321
(mnowzari)

documentation

README

Alembic

Log once, send anywhere.

Send the same log message to stdout, stderr and a log file at the same time, with a single function call!

Currently supported output sinks:

  • stdout
  • stderr
  • Log file
    • Rotation policies (hourly, daily, weekly and monthly)

To-do

  • Elasticsearch sink

Example: Write to a stdout and File sink simultaneously

// Create a log handler. Default log level is Error.
let mut logger: Handler = Handler::new().unwrap();

// Create stdout and file sink instances
let mut stdout_sink: StdoutSink = Stdout::new().unwrap();
let mut file_sink: FileSink = FileSink::new(
  PathBuf::from("./my_application.log"),
  alembic::filesink::RotationPolicy::Weekly
).unwrap();

// Add the sinks to the log handler
logger.add_sink(Box::new(stdout_sink));
logger.add_sink(Box::new(file_sink));

// Write some logs!
logger.info("Hello, Alembic!")
logger.error("Oh dear, there's been a terrible error.")

The log line format

Log formats are currently non-adjustable. Here is an example log line that is generated by Alembic:

[2025-08-03T14:51:54.936003992-04:00] [DEBUG] [file] There is a bug!
[2025-08-03T14:51:54.936172325-04:00] [INFO] [file] Wow, so informational.
[2025-08-03T14:51:54.936190558-04:00] [WARN] [file] WARNING
[2025-08-03T14:51:54.936206347-04:00] [ERROR] [file] ! ERROR !
[2025-08-03T14:51:54.936221734-04:00] [FATAL] [file] FATALITY.

Building from source

The project is buildable directly via

cargo build

However, we also have a Makefile to make common development actions easier.

make build         # development build
make build-release # release build

The Makefile has several other functions defined as well - check the file for a complete accounting of commands.

Commit count: 25

cargo fmt