Coder Social home page Coder Social logo

spinlog.py's Introduction

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

spinlog.py's People

Contributors

adrieankhisbe avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.