simpidlog is a small Python logging helper that writes messages from a
background thread into per-level log files while optionally printing colored
messages to the console.
- asynchronous log writing through an internal queue
- separate log files for
info,warning,error, anddebug - optional colored terminal output
- simple API with no configuration objects
pip install simpidlogFor local development:
pip install -e .from simpidlog import debug, error, info, set_basedir, wait_for_log_io, warning
set_basedir(".")
info("training started")
warning("learning rate looks high")
error("dataset file is missing")
debug("batch size = 32")
wait_for_log_io()You can still import the module itself with from simpidlog import logger, but
the common logging helpers are now also re-exported at the package level.
This creates a directory like ./logs/2026-03-24_12-34-56/ containing:
info.txtwarning.txterror.txtdebug.txt
Each line is timestamped and prefixed with its log level.
Sets the root directory where the logs/ folder will be created.
Returns the current log base directory.
Queues an info message. When output=True, the message is printed and written
to info.txt. When output=False, it is still written to disk and the colored
string is returned instead of being printed.
Queues a warning message and writes it to warning.txt.
Queues an error message and writes it to error.txt.
Queues a debug message and writes it to debug.txt. Debug output is not printed
by default.
Flushes queued messages and stops the background logging thread. Call this near program exit if you need to make sure every pending message has been written.
The simpidlog.colorful module also exposes string helpers:
color_print_str(s, ccode)red_print_str(s)green_print_str(s)yellow_print_str(s)blue_print_str(s)
These helpers return colored strings and do not print by themselves.
- log files are grouped by the timestamp of the worker start time
- the background worker is started automatically when
simpidlog.loggeris imported - after calling
wait_for_log_io(), do not queue more messages in the same process unless you add your own restart logic