Skip to main content

A debug Python package

Project description

DEBUG2

This library helps in debug activity.

No more putting print in between lines of big scripts and trying to do the RCA.

The library helps you store the entries of each debug points, as effortlessly as print.

The entries are stored in json format.

The entries helps in creating a lineage of the script execution.

There are 2 available methods in this package :

  • dprint
  • dprint2

dprint

This method is for simple use cases.

It takes 3 input parameters :

  • param_name - the label for the parameter
  • param_value - the value of the parameter
  • file_name (optional) - for storing the entries in json format.

By default the file name for storing the entries is debug_db.json. Custom name and path can be provided.

dprint2

This method is for advanced use cases.

It takes 5 input parameters :

  • script_name - name of the script from which the call is made.
  • execution_id - this is to keep the entries of each execution in separate files.
  • param_name - the label for the parameter
  • param_value - the value of the parameter
  • file_name (optional) - for storing the entries in json format.

The json file is in the format of TinyDB, hence portable, and can be easy parsed, with each entries, with their own doc_id.

Usage

Here is a simple example on how to use the package :

from debug2 import debug2 as dbg
dbg_file_name ='123debug'

def add(a,b):
    return a+b
    
def sub(a,b):
    return a-b

def mul(a,b):
    return a*b

def avg(a,b):
    return (a+b)/2
    

if __name__ == "__main__":

    data = {"type":"credit",
            "balance":10000,
            "amount":200}

    if data["type"] == 'credit':
        balance = add(data["balance"],data["amount"])
        dbg.dprint("new_balance",balance)

        
    if data["type"] == 'debit':
        balance = sub(data["balance"],data["amount"])
        dbg.dprint("new_balance",balance,"debit")

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

debug2-0.1.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

debug2-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file debug2-0.1.0.tar.gz.

File metadata

  • Download URL: debug2-0.1.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for debug2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd64dc78b6f10da02a5a77037e3de24cda89b4cf4798abef8a5435423529d715
MD5 f693ecc8afc1ed620fabb93a39e9d325
BLAKE2b-256 cb2d3ef480047789b1e764f707788d3bb41d99a12da4b35efa50d427326d46a8

See more details on using hashes here.

File details

Details for the file debug2-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: debug2-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for debug2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a1185efbfdff2155f3de2c986bded2a2f55e08862c327817d54e85c68a0191f
MD5 bcd147b6caa01d0850c9131b3517b4a1
BLAKE2b-256 d7b73677059cbc12c4e271e18e7e8a21b6439b6ab2d80e65af39fdb21c079a37

See more details on using hashes here.

Supported by

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