tasklogger
Project description
An extension to the core python logging library for logging the beginning and completion of tasks and subtasks.
Installation
tasklogger is available on pip. Install by running the following in a terminal:
pip install --user tasklogger
Alternatively, tasklogger can be installed using Conda (most easily obtained via the Miniconda Python distribution):
conda install -c conda-forge tasklogger
Usage examples
Receive timed updates mid-computation using tasklogger.log_start and tasklogger.log_complete:
>>> import tasklogger >>> import time >>> tasklogger.log_start("Supertask") Calculating Supertask... >>> time.sleep(1) >>> tasklogger.log_start("Subtask") Calculating Subtask... >>> time.sleep(1) >>> tasklogger.log_complete("Subtask") Calculated Subtask in 1.01 seconds. >>> time.sleep(1) >>> tasklogger.log_complete("Supertask") Calculated Supertask in 3.02 seconds.
Simplify logging syntax with tasklogger.log_task:
>>> import tasklogger >>> import time >>> with tasklogger.task("Supertask"): ... time.sleep(1) ... with tasklogger.log_task("Subtask"): ... time.sleep(1) ... time.sleep(1) Calculating Supertask... Calculating Subtask... Calculated Subtask in 1.01 seconds. Calculated Supertask in 3.02 seconds.
Log wall time, CPU time, or any other counter function with the class API:
>>> import tasklogger >>> import time >>> logger = tasklogger.TaskLogger(name='cpu_logger', timer='cpu', min_runtime=0) >>> with logger.task("Supertask"): ... time.sleep(1) ... with logger.task("Subtask"): ... time.sleep(1) ... time.sleep(1) Calculating Supertask... Calculating Subtask... Calculated Subtask in 0.00 seconds. Calculated Supertask in 0.00 seconds. >>> logger = tasklogger.TaskLogger(name='nano_logger', timer=time.monotonic_ns, min_runtime=0) >>> with logger.task("Supertask"): ... time.sleep(1) ... with logger.task("Subtask"): ... time.sleep(1) ... time.sleep(1) Calculating Supertask... Calculating Subtask... Calculated Subtask in 1001083511.00 seconds. Calculated Supertask in 3003702161.00 seconds.
Use tasklogger for all your logging needs:
>>> tasklogger.log_info("Log some stuff that doesn't need timing") Log some stuff that doesn't need timing >>> tasklogger.log_debug("Log some stuff that normally isn't needed") >>> tasklogger.set_level(2) Set TaskLogger logging to DEBUG >>> tasklogger.log_debug("Log some stuff that normally isn't needed") Log some stuff that normally isn't needed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tasklogger-1.0.0.tar.gz
.
File metadata
- Download URL: tasklogger-1.0.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60001bc45200e036ef4a253043a713ae2dce7d070f4586d4e1144f7b7549d6f4 |
|
MD5 | 8ee70e4a6d03e1e2bfd94062d1540a6a |
|
BLAKE2b-256 | 53d25050df00f10696e0cf4d3e60c707635e2eb61c806c7a73d687e902b46002 |
File details
Details for the file tasklogger-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: tasklogger-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70eef6ec022de885af774c84575d36d9e9006c7844724e75db7ff7ecb5998039 |
|
MD5 | 808685caa038c7f4f10fc5ad62d4c704 |
|
BLAKE2b-256 | 5d6bcb2a724eff19829a0ada0217f403f54fca1e48c7de6fc3383e0a8b8fa121 |