A unified Logger and ProgressBar util with zero dependencies.
Project description
LogBar
A unified Logger and ProgressBar util with zero dependencies.
Features
Oncelogging:log.info.once("this log msg will be only logged once")- Progress Bar:
progress_bar = log.pb(100) - Sticky Bottom Progress Bar: Default behavior!
- Logging and Porgress Bar work hand-in-hand with no conflict: logs are printed before the progress bar
Usage:
# logs
log = LogBar.shared() # <-- single global log (optional), shared everywhere
log.info("super log!")
log.info.once("Show only once")
log.info.once("Show only once") # <-- not logged
# progress bar
pb = log.pb(100) # <-- pass in any iterable or int
for _ in pb:
time.sleep(0.1)
# advanced progress bar usage
# progress bar with fixed title
pb = log.pb(100).title("Super Bar:") # <-- set fixed title
for _ in pb:
time.sleep(0.1)
# advanced progress bar usage
# progress bar with fixed title and dynamic sub_title
# dynamic title/sub_title requires manual calls to `draw()` show progress correctly in correct order
pb = log.pb(names_list).title("Processing Model").manual() # <-- switch to manual render mode: call `draw()` manually
for name in pb:
start = time.time()
log.info(f"{name} is about to be worked on...") # <-- logs and progress bar do not conflict
pb.subtitle(f"Processing Module: {name}").draw()
log.info(f"{name} completed: took {time.time()-start} secs")
time.sleep(0.1)
tqdm replacement
Replacing tqdm with logbar is effortless and most time most pythonic and easier to use while being more powerful in the construction
Simple
# tqdm
sum = 0
for n in tqdm.tqdm(range(1000)):
sum += n
time.sleep(0.1)
# logbar
sum = 0
for n in log.pb(100,000):
sum += n
time.sleep(0.1)
Manul Update
# tqdm, manual update mode
with tqdm.tqdm(total=len(f.keys())) as pb:
for k in f.keys():
x = f.get_tensor(k)
tensors[k] = x.half()
del x
pb.update()
# manual render mode, call ui render manually in each step
with log.pb(f.keys()) as pb:
for k in pb:
x = f.get_tensor(k)
tensors[k] = x.half()
del x
pb.render()
Pending Features
- Multiple Active Progress Bars
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
logbar-0.0.5.tar.gz
(13.2 kB
view details)
File details
Details for the file logbar-0.0.5.tar.gz.
File metadata
- Download URL: logbar-0.0.5.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b354247f98ecddb84c37f247042b472527178102a3963b4ff52a51b0e782e28
|
|
| MD5 |
b998435d175b1e6c5c831197058a3faf
|
|
| BLAKE2b-256 |
22bac061bf65c54dfb070c842345933e8edd3cec1a0db21447d3bb8b8671cb01
|