Skip to main content

Spinner Logger for Python

Project description

spinlog.py

PyPI Supported Python Versions Build Status codecov

Spinner Logger for Python

Installation

Just pip install spinlog and you can use it.

Usage

Spinlog is build on top of halo providing a different API to interact with the spinner.

Basic Usage

from spinlog import Spinner
from time import sleep

print("About to launch Spinner")
with Spinner.get("I'm spinning around") as s:
    sleep(2)
    s.info("Here is an info message while spinning around")
    # you can use s.warn, s.error, or s.debug
    sleep(2)
print("Spinning Over")

Advanced usage

Spinlog is build in such a manner that you can disable the spinning animation and replace it with proper logging without having to change the codebase.

This is done by creating a spinner instance, potentialy configured with two logger, the concommitant_logger to be run alongside the spinner (for logging to file for instance), and the alternative_logger to replace spinner animation and logging.

A complete example can be found in the examples folder Here is an except:

# imports and logger definitions
should_spin = "--no-spin" not in sys.argv
# Configure spinner
spinner = Spinner(spinner="triangle", is_spinning=should_spin,
                  alternative_logger=stream_logger, concommitant_logger=file_logger)
# Use spinner
with spinner("Operation in progress") as s:
    sleep(2)
    s.info("Checkpoint reached")
    sleep(2)

Licence

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.

Source Distribution

spinlog-0.3.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

spinlog-0.3.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

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