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

Non-intrusive spinner through standard logging library

Project description

Latest PyPI version Build Status Demo session

This library helps to display loading spinners in CLI in non-intrusive manner. Applications/libraries don’t have to depend on any third-party API, but only need to log loading messages through Python’s standard logging library:

logger = logging.getLogger('myapp.logger')
logger.info('Loading data...', extra={'user_waiting': True})
# some long taking process goes here...
logger.info('Finished loading!', extra={'user_waiting': False})

At the outest code of the application, setup a SpinnerHandler:

from logging_spinner import SpinnerHandler

logger = logging.getLogger('myapp')
logger.setLevel(logging.INFO)
logger.addHandler(SpinnerHandler())

SpinnerHandler is only aware of log records with user_waiting extra field and displays them with a spinner.

See also sample.py code.

Author and license

Written by Hong Minhee and distributed under GPLv3 or later.

Changelog

Version 0.2.2

Released on June 22, 2017.

  • Fixed a ValueError raised when a log record with {'user_waiting': Flase} is made without any previous log records with {'user_waiting': True}.

Version 0.2.1

Released on May 21, 2017.

  • Fixed a bug that SpinerHandler had crashed when user_waiting log records show a spinner again after a previous spinner was hidden.

Version 0.2.0

Released on May 21, 2017.

  • logging_spinner.UserWaitingFilter was introduced to avoid duplicate prints of a log record with user_waiting extra field.

Version 0.1.0

Released on May 21, 2017. The initial release.

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 logging-spinner, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size logging_spinner-0.2.2-py2.py3-none-any.whl (5.4 kB) File type Wheel Python version 3.6 Upload date Hashes View hashes
Filename, size logging-spinner-0.2.2.tar.gz (3.8 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