Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Log by overwriting the previous output in the terminal

Project description

logupdate.py

PyPI Supported Python Versions Build Status

Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc. (Port of sindresorhus/log-update from js to python)

Install

Just pip install it, and you're good to go.

pip install logupdate

Usage

from logupdate import logupdate
from time import sleep

logupdate("Hello, a secret is about to be said to you")
sleep(1)
logupdate("You can pimp your interactive commands with logupdate")
sleep(1)
logupdate("Don't forget the secret ;)")
sleep(1)
logupdate.clear().done()

Examples

You can find some example in the dedicated examples folder.

API

  • logupdate(text, ...): log to stdout (overwriting previous input)

  • logupdate.clear([restore_cursor=None]): Clear previous logged output. This can also restore the cursor if asked.

  • logupdate.done([restore_cursor=None]): Persist the logged output. This enable to start a new "log session" below. This restores the cursor unless you ask not to.

  • logupdate.stderr(text, ...): log to stderr

  • logupdate.stderr.clear([restore_cursor=None]): clear stderr.

  • logupdate.stderr.done([restore_cursor=None]): persist stderr.

  • logupdate.create(stream, [show_cursor=False]) : return a logupdate method dedicated to log to given stream.

License

MIT © AdrieanKhisbe

Project details


Download files

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

Files for logupdate, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size logupdate-0.3.0-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size logupdate-0.3.0.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page