Skip to main content

Turn comments into logs

Project description

commentlogger

Convert your comments into log lines

Install from PyPI

pip install commentlogger

I'm a weirdly lazy developer. I like viewing the maximum amount of code/logic on one screen. I also dislike (especially when I'm newly developing some logic) having to read (and ignore) log lines. Logging is hugely important and should be a part of any production code. But I personally hate having to read past logging code when I'm trying to develop/debug core logic.

Nevertheless, having logging functionality is useful even while developing the code, especially when the project complexity increases. This project aims to solve this problem by turning inline comments into log lines.

Example

Code

import logging

import commentlogger


logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger(__name__)


@commentlogger.logComments(logger)
def foo(a,b):
    a += 1  # increment for stability
    b *= 2  # multiply for legal compliance

    # compute sum
    answer = a+b
    return answer


def bar(a,b):
    a += 1  # increment for stability
    b *= 2  # multiply for legal compliance

    # compute sum
    answer = a+b
    return answer


if __name__ == "__main__":
    print('starting')

    foo(2,3)
    bar(1,2)

    print('done')

Output

$ python test.py
starting
[foo:12] increment for stability
[foo:13] multiply for legal compliance
done

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

commentlogger-0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

commentlogger-0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file commentlogger-0.2.tar.gz.

File metadata

  • Download URL: commentlogger-0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for commentlogger-0.2.tar.gz
Algorithm Hash digest
SHA256 fde8d39cef1ee45fe2dc3f62038130a8711820f9554d35b26033a35161497ef7
MD5 425143352c79a7e94aa127b4ae9e8d97
BLAKE2b-256 79341f34656b26a7dbadfe91a234ae16524d502b2afc43e9afa938c4864a3b56

See more details on using hashes here.

File details

Details for the file commentlogger-0.2-py3-none-any.whl.

File metadata

  • Download URL: commentlogger-0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for commentlogger-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f6ee0df1dfb95f73ebc1581375cc25ebfa9d6b699a4fed7efce064827304c1e
MD5 0247c7336a24dc7d08e067098c56ef59
BLAKE2b-256 a3a124833f0cac2abfbb6b6d3ba2e0f9621da692d85c20018ff05875567612e1

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