Skip to main content

A Python package to add extensive logs to each execution statement

Project description

crazylog

crazylog logs like crazy. Allows to add extensive logging at each step in the python execution cycle.

Installation

You can install from pypi:

pip install -U crazylog

Or get the latest updates (Not recommended for production):

pip install -U git+https://github.com/afarntrog/crazylog.git

Quickstart

Here you can see a few samples to get a feel of whats ahead.

Basic example

from crazylog import CrazyLogger

def foo():
   print('running code ...')

with CrazyLogger() as crazy:
   foo()

Run it for specific classes only

class CustomClass:
   pass

with CrazyLogger() as crazy:
   crazy.exclusively = [CustomClass]
   foo()

Apply it manually to specific classes via metaclasses

Run the code as usual. CrazyLogger will kick in if that class is called

from crazylog import CrazyLoggerMeta

class CustomClass(metaclass=CrazyLoggerMeta):
   def printer(self):
      print('CrazyLogger is active')

def foo():
   print('CrazyLogger will do nothing')
   CustomClass().printer()

# run as usual
foo()

Apply it at the module level

apply should be added at the bottom of the module that you want it to take affect.

# my_first_module.py
from crazylog import CrazyLogger

class CustomClass():
   def printer(self):
      print('CrazyLogger is active')

def foo():
   print('CrazyLogger is active')
   CustomClass().printer()

CrazyLogger.apply(__name__)

# my_second_module.py
from my_first_module import foo

def bar():
   print('CrazyLogger is not active in this module - only in my_first_module')

foo()

# CrazyLogger only has an effect when `foo` is called.

Feedback and contributing

This library is very focused on being easy and fun to use, so if you find something that you think can be improved please open an issue or even better, a PR, thank you!

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

crazylog-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

crazylog-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file crazylog-0.1.1.tar.gz.

File metadata

  • Download URL: crazylog-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

File hashes

Hashes for crazylog-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9e5e53cf8cec892e820b91d81f21246f118b2d6c7589d119444444241cd0629e
MD5 d5f7f3db283bb8c5cc809f4db919ad4a
BLAKE2b-256 de02a84eecf5487040cea367ab54639def9b79b557f1591381e0899b4f90598f

See more details on using hashes here.

File details

Details for the file crazylog-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: crazylog-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

File hashes

Hashes for crazylog-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af7c05810ae968982f307b4f690911518eee2604ad0bb0291fcfbbef84e9601e
MD5 429cbb3f3760cb7c187a41bb73da3938
BLAKE2b-256 44a1aedea7dd6b0e0a161d6da69a7cea16493b1c444c315c9e80800a6dea25e5

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