Skip to main content

A simple, lightweight logger for your Python loops

Project description

Progress Logger

pip install progresslogger

Progress Logger is a simple, lightweight logger for your Python loops. Quickly see the current status of long loops, its estimated time remaining, and more useful stats!


Simple Usage

Progress Logger works great right out of the box, with no customization required. When imported, it will overwrite the built-in enumerate() function. That's it!

from progresslogger import *

my_list = ['a', 'b', 'c', 'd', 'e']

for i, letter in enumerate(my_list):
    execute_code(letter)

Output:

>>> Starting progress logger for 5 items.
>>> Iteration 1 of 5 (20.0%) complete. Approximately 4 seconds remaining.
>>> Iteration 2 of 5 (40.0%) complete. Approximately 3 seconds remaining.
>>> ...
>>> Loop complete! Average iteration time: 1.0 seconds

Advanced Usage

You may customize your logger and pass it directly to the enumerate() function:

my_logger = ProgressLogger(show_next_value=True)
for i, letter in enumerate(my_list, my_logger):
    execute_code(letter)

Output:

>>> Starting progress logger for 5 items. Next value: "a".
>>> Iteration 1 of 5 (20.0%) complete. Approximately 4 seconds remaining. Next value: "b".
>>> Iteration 2 of 5 (40.0%) complete. Approximately 3 seconds remaining. Next value: "c".
>>> ...

If you'd like to retain the built-in enumerate() function, or you'd like to have both, you can use from progresslogger import ProgressLogger or import progresslogger and use progresslogger.enumerate(...).

You may wish to insert the log in the middle of a loop, or otherwise implement your logger yourself. Simply initialize ProgressLogger before the loop, and call my_logger.log() once each loop:

my_logger = ProgressLogger(my_list) # be sure to pass your collection when initializing your logger
for letter in my_list:
    my_logger.log()
    execute_code(letter)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

progresslogger-1.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file progresslogger-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: progresslogger-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.4

File hashes

Hashes for progresslogger-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d89bac00bde3fa0d7920802330f82d038532fae939968b8d2a00ae8afba276
MD5 f7920837de0a76ece3b2d2066926e7a4
BLAKE2b-256 2df3209018f6813091a9d596a3a9b469140c5fad15b5e188c4b6fbe5417f7703

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page