Skip to main content

Elegant Console Logger For Python Command Line Apps

Project description

Signale.py

Elegant Console Logger For Python Command-Line Apps



example

Installation

Signale.py can be installed using pip.

    [sudo] pip install signalepy

Usage

Package consists of a class Signale, it is the main constructor class. The object created has all the logger functions in it.

Using Loggers

Each logger function takes in three arguments:-

  • text
  • prefix ( Optional )
  • suffix ( Optional )

They all are available in the logger object. To create one do this:-

    from signalepy import Signale

    logger = Signale()

Now you can use the default loggers using this object like:-

    ...

	logger.success("Started Successfully", prefix="Debugger")
	logger.warning("`a` function is deprecated", suffix="main.py")
	logger.complete("Run Complete")

    ...

This will produce the following result:-



View All Available Loggers
  • simple
  • success
  • error
  • warning
  • start
  • stop
  • watch
  • important
  • pending
  • complete
  • debug
  • pause
  • info
  • like
  • center

Scoped Loggers

To create scoped loggers, define the scope field in the options argument of constructor like:-

	from signalepy import Signale

    logger = Signale({
    	"scope": "global scope"
    })
    logger.success("Scoped Logger Works!")

This will produce the following result:-



You also create multiple scopes by setting the scope field to a list of strings like:-

	from signalepy import Signale

    logger = Signale({
    	"scope": ["global scope", "inner scope"]
    })
    logger.success("Scoped Logger Works!")

This will produce the following result:-




You can also create scoped a logger which is just clone of other by using by using the scoped function like this:-

	from signalepy import Signale

	logger = Signale({
		"scope": "global scope"
	})

	logger2 = logger.scoped("inner")
	logger2.like("I love Signale.py", prefix="Shardul Nalegave", suffix="Creator")

This will produce the following result:-


Note:- All the configuration will be copied to the new logger just the scope will be extended.


API

  1. logger = Signale(<options>)


    Signale

    • Type: class

    Signale class imported from signalepy module


    options

    • Type: dict

    Options Dictionary for logger.


    • Returns: Signale Logger Object

    Logger object which can be used for logging



  2. logger.<logger>(message="", prefix="", suffix="")


    logger

    • Type: function

    Can be any default logger


    message

    • Type: str

    Message to be displayed


    prefix

    • Type: str
    • Required: False

    Prefix text


    suffix

    • Type: str
    • Required: False

    Suffix text


    • Returns: None



  3. logger2 = logger.scoped(<new scope>)


    logger

    • Type: Signale Logger Object

    Parent Logger


    new scope

    • Type: str

    New Scope Name


    • Returns: Signale Logger Object

    Clone Logger object with extended scope




Licensed Under MIT License A Project By Shardul Nalegave

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

signalepy-0.2.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

signalepy-0.2.1-py3-none-any.whl (12.8 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