Skip to main content
goatl logo

goatl

Build status Python Version Dependencies Status

Code style: black Coverage Report

Installation

pip install -U goatl

or install with Poetry

poetry add goatl

Purpose

goatl provides a simple and easy to use logging interface for python projects. by replacing repetitive boilerplate code with a simple function call: the magic "log" function.

from goatl import log

goatl usage is all about the log

Usage

as a function

log("hello world")
# 2020-07-19 16:00:00,000 - goatl - INFO - hello world
log.debug("hello world?")
# 2020-07-19 16:00:00,000 - goatl - DEBUG - hello world?
log.info("do you know the answer of {} + {}?", 41, 1)
# 2020-07-19 16:00:00,000 - goatl - INFO - do you know the answer of 41 + 1?

as a method decorator

@log
def foo(x, y):
    return x + y

@log.debug
def bar():
    return "hello world"

@log.debug(return_level=log.info)
def baz(x):
    return x*2

foo(1, 2)
# ... INFO - foo called with args: (1, 2), kwargs: {}
# ... DEBUG - foo returned: 3
bar()
# ... DEBUG - bar called with args: (), kwargs: {}
# ... DEBUG - bar returned: hello world
baz(3)
# ... DEBUG - baz called with args: (3,), kwargs: {}
# ... INFO - baz returned: 6

as a class decorator

@log
class Foo:
    def __init__(self, x):
        self.x = x

    def bar(self, y):
        return self.x + y

    @log.warn
    def baz(self):
        return self.x * 2


foo = Foo(1)
# ... INFO - Instantiated Foo with args: (1,), kwargs: {}
foo.bar(2)
# ... INFO - Foo.bar called with args: (2,), kwargs: {}
# ... DEBUG - Foo.bar returned: 3
foo.baz()
# ... WARNING - Foo.baz called with args: (), kwargs: {}
# ... WARNING - Foo.baz returned: 2

configurations shortcuts

file_formatter = log.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
log.addFileHandler("foo.log", fmt=file_formatter)
log.addStreamHandler(fmt="%(levelname)s - %(message)s")
log.basicConfig(...)

logging interface #not implemented yet

I do plan to implement goatl's interaction with logging through an interface such that it will be possible to use goatl with any logging backend.

log.setBackend(logging)
log.setBackend(loguru)
logger = log.getLogger("foo")

core concepts

In order to justify the existence of goatl, it must fulfill three important core concepts:

  1. Unobtrusive - it should not interfere* with the existing code.
  2. Ease of use - using it should be intuitive and pythonic.
  3. Clean - the amount of code added to the existing code should be minimal.

* - logging will always carry a performative cost, goatl will aim at keeping it to a minimum.

means

extensive testing of goatl must be implemented to ensure that it does not interfere with the existing code. it should be tested by wrapping other popular libraries and modules with goatl. this will ensure that goatl does not interfere with the existing code. performance tests should be implemented to measure the performance cost of goatl, it should not exceed a reasonable threshold, in comparison to adding logging manually.

main features

the log function provides an easy interace for:

  • out of and in context log calls
  • wrapping existing functions with log calls
  • wrapping existing classes with log calls
  • wrapping existing modules with log calls #not implemented yet, is this even possible?
  • logging configuration #not implemented yet
  • support multiple logging backends #not implemented yet

all in an intuitive and pythonic way.

Releases

You can see the list of available releases on the GitHub Releases page.

License

License

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Citation

@misc{goatl,
  author = {goatl},
  title = {goat logger},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/EytanDn/goatl}}
}

Metadata

Release files for goatl 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for goatl 0.6.5
File Size Uploaded
goatl-0.6.5.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for goatl 0.6.5
File Interpreter ABI Platform
goatl-0.6.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / goatl-0.6.5.tar.gz

Download URL goatl-0.6.5.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fa208852669ca2075d8e6f03c3060fc283ea16234984f1e1899351a421fa2f1e
BLAKE2b-256 checksum
How to use checksums
9f54e5d9106ff6cb0d5a99aeebe4115e3b2bf18f1b03ae60080c64fb0c3f2cb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.12 Windows/10

Release files / goatl-0.6.5-py3-none-any.whl

Download URL goatl-0.6.5-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e8e3fef840f1302e78849ed115659a97e96b2006420c64d441163ef293ed76c
BLAKE2b-256 checksum
How to use checksums
2c2ac1da666b8e3b61d99c6c03670bbbdac55f86bdb91c06b132bda4d950974f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.12 Windows/10

Release history Release notifications | RSS feed

This release

0.6.5 This release

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.0

2 release files

0.4.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page