#log #logger #logging #thread

file-per-thread-logger

A logging implementation that writes logs in one file per thread

6 releases

0.1.5 Feb 5, 2022
0.1.4 Aug 20, 2020
0.1.3 May 14, 2020
0.1.2 Jan 3, 2019
0.1.0 Jul 30, 2018

#60 in Debugging

Download history 17998/week @ 2022-04-21 17056/week @ 2022-04-28 18412/week @ 2022-05-05 19973/week @ 2022-05-12 20237/week @ 2022-05-19 16313/week @ 2022-05-26 17833/week @ 2022-06-02 21453/week @ 2022-06-09 20198/week @ 2022-06-16 20673/week @ 2022-06-23 18977/week @ 2022-06-30 20572/week @ 2022-07-07 22791/week @ 2022-07-14 23260/week @ 2022-07-21 23955/week @ 2022-07-28 24126/week @ 2022-08-04

98,363 downloads per month
Used in 32 crates (2 directly)

Apache-2.0 WITH LLVM-exception

10KB
108 lines

File per thread logger

This is a thread-safe logger that will write logs to files, each thread owning its own file.

Usage

Put this in your Cargo.toml:

[dependencies]
file-per-thread-logger = "0.1.2"

Then add this to your code, once per thread:

file_per_thread_logger::initialize("file_prefix-");

Then each use of log's primitive will log into files named the following way:

  • the main thread get a file that's suffixed after the program's name.
  • unnamed threads get a file suffixed with ThreadIdN where N is the thread's id number.
  • named threads get a file suffixed with the thread's name.

Dependencies

~1.2–1.7MB
~44K SLoC