5 unstable releases

0.2.1 Apr 29, 2023
0.2.0 Apr 21, 2023
0.1.0 Apr 21, 2023
0.0.2 Apr 21, 2023
0.0.1 Apr 21, 2023

#1327 in Algorithms

Custom license

6KB
54 lines

satlog.rs: Simple logger for SAT-like solvers

This outputs logs to stdout as DIMACS comments:

c WARN: ...
c ERR: ...

For Level::Info messages, the level is not printed: this allows to have a quiet mode for the solver by setting the level filter to LevelFilter::Off.

Example usage

use satlog::SatLogger;
use log::LevelFilter;

fn main() {
    SatLogger::init(LevelFilter::Info);
}

Limitations / TODOs

  • Allow configuring the prefix for multiline log messages

lib.rs:

satlog.rs is a simple and minimalistic logger designed for SAT solvers and the likes, following the DIMACS syntax of comments starting with c.

The main interaction and setup is done through the [SatLogger] struct.

This plugs into the generic log crate and simply displays the messages to stdout.

Some neat features:

  • Messages with level Level::Info are displayed without prefix. This allows to show "default" logging messages and toggle them with the LevelFilter::Off.
  • Opt-out colors with the color feature.

Example

use satlog::SatLogger;
use log::LevelFilter;

fn main() {
    SatLogger::init(LevelFilter::Info);

    log::info!("Hello");
    log::trace!("Will not display");
}

Dependencies

~0–9MB
~52K SLoC