Simple, thread-safe, counter based progress logging

Related tags

GUI proglog
Overview

🦫 proglog

Build Status license Version info

Documentation Crates.io

This is a simple, thread-safe, count-based, progress logger.

Synopsis

proglog hooks into your existing log implementation (i.e. env_logger) and will output a log message every unit number of items it has seen. There are two primary methods, record() and record_with(...). record() simply increments the counter and will cause a log message to output when counter % unit == 0. record_with(Fn() -> impl Display) takes a function that outputs anything implementing display which will be appended to the log message.

How to use this

Add to your deps:

cargo add proglog

Usage

Please see the rayon example.

use proglog::ProgLogBuilder;

// Note a `log` backend needs to be globally initialized first
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();

let logger = ProgLogBuilder::new().build();
for i in 0..10_000 {
    logger.record_with(|| format!("Logged item: {}", i));
}

// The logger will flush when it is dropped, writing a final progress message no mater the count.
// Alternatively you can call .flush() or .flush_with().

Things to know

If unit is too small, and your loop is too tight, this will output many log messages which will slow your program down in the same way any logging would slow a program down in a hot loop. If unit is sufficiently large, this should be safe to put in a hot loop as all it does increment update an atomic u64.

If your loop is tight, unit is small, and you are using rayon / updating from multiple threads your log messages may end up out of order. There is no guaranteed ordering of the submission of the log message to the logger. So thread A could hit the first unit break, thread B could hit the second point at the same time, but thread B gets to submit its log message first. Having sufficiently large unit will mitigate this, but you should not be depending on the log output order here. The tradeoff made is for speed of incrementing so this can be put in hot loops over guaranteed output ordering.

Features

pretty_counts

The pretty_counts features turns on the ability to format the numbers in the log messages. Set the [ProgLogBuilder::count_formatter] to one of the [CountFormatterKind]s and numbers will be formatted accordingly. i.e. 100000000 -> 100_000_000 with [CountFormatterKind::Underscore].

Tests

cargo test

Direct Inspirations

  • The ProgressLogger found in fgpyo
  • The ProgressLogger in fgbio
You might also like...
a day-planner/calendar app based on egui
a day-planner/calendar app based on egui

Malakal Malakal is a day planner application. I crafted it because I was not able to find a comfortable calendar application for Linux. I myself have

A fast, zbus-based, permissively licensed AT-SPI library written in pure Rust!

AT-SPI for Rust Higher level, asynchronous Rust bindings to AT-SPI2, using zbus. Part of the Odilia screen reader project. Design Fully documented, wi

Create dynamic grid-based layouts for egui

egui_grid Create dynamic grid layouts for egui. Grids are flexible, easy to create, with behavior similar to egui_extra's strip creation. They're comp

Generates a theme for Egui based on M3 color palettes.
Generates a theme for Egui based on M3 color palettes.

M3-EGUI About M3-EGUI (material-egui) is a library that takes an input color and generates a color palette using M3 colors. It then applies those colo

A simple, cross-platform GUI automation module for Rust.

AutoPilot AutoPilot is a Rust port of the Python C extension AutoPy, a simple, cross-platform GUI automation library for Python. For more information,

A simple UI framework for Rust built on top of IUP (http://webserver2.tecgraf.puc-rio.br/iup/)

KISS-UI A UI framework for Rust based on the KISS (Keep It Simple, Stupid!) philosophy. Powered by the IUP GUI library for C by Tecgraf, via the bindi

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Marko Editor is a simple WYSIWYG editor for note taking.
Marko Editor is a simple WYSIWYG editor for note taking.

Marko Editor Marko Editor is a simple WYSIWYG editor for note taking written in Rust and GTK 4. It uses Markdown as storage format and can read simple

A simple news reading GUI app built in Rust
A simple news reading GUI app built in Rust

Headlines [WIP] A native GUI app built with Rust using egui. Uses newsapi.org as the source to fetch news articles. This is a WIP and the current stat

Owner
Seth
Rust, Bioinformatics
Seth
Unsafe bindings and a safe wrapper for gtk4-layer-shell, automatically generated from a .gir file

gtk4-layer-shell: gtk4-layer-shell-sys: gtk4-layer-shell This is the safe wrapper for gtk4-layer-shell, automatically generated from its .gir file. Fo

null 3 Apr 30, 2023
A simple GUI version of the pH calibration tool written in egui, based on the eframe template.

caliphui A simple GUI version of the pH calibration tool written in egui, based on the eframe template. Usage Native binaries are provided under relea

Peter Dunne 0 Dec 29, 2021
Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust

Relm Asynchronous, GTK+-based, GUI library, inspired by Elm, written in Rust. This library is in beta stage: it has not been thoroughly tested and its

null 2.2k Dec 31, 2022
Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process.

Envfs Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process. This is useful to execute shebangs on NixOS th

Jörg Thalheim 98 Jan 2, 2023
Termbox is a library that provides minimalistic API which allows the programmer to write text-based user interfaces.

Termbox is a library that provides minimalistic API which allows the programmer to write text-based user interfaces.

null 1.9k Dec 22, 2022
A floating, tag-based window manager written in Rust

worm worm is a floating, tag-based window manager for X11. It is written in the Rust programming language, using the X11RB library. Install cargo buil

null 627 Jan 4, 2023
GUI based tool to sort and categorize images written in Rust

ImageSieve GUI based tool to sort out images based on similarity, categorize them according to their creation date and archive them in a target folder

Florian Fetz 67 Dec 14, 2022
An idiomatic GUI library inspired by Elm and based on gtk4-rs

An idiomatic GUI library inspired by Elm and based on gtk4-rs. Relm4 is a new version of relm that's built from scratch and is compatible with GTK4 an

Aaron Erhardt 722 Dec 31, 2022
A lightweight cross-platform system-monitoring fltk gui application based on sysinfo

Sysinfo-gui A lightweight cross-platform system-monitoring fltk gui application based on sysinfo. The UI design is inspired by stacer. The svg icons a

Mohammed Alyousef 22 Dec 31, 2022
Unofficial Linux QQ client, based on GTK4 and libadwaita, developed with Rust and Relm4.

GTK QQ (WIP) Unofficial Linux QQ client, based on GTK4 and libadwaita, developed with Rust and Relm4. Screenshots Light Dark Note The two screenshots

Lomírus 198 Dec 24, 2022