Skip to main content

A simple logging utility.

Project description

loggy

A simple logging utility.

Badge for GitHub issues. Badge for GitHub forks. Badge for GitHub stars. Badge for GitHub license, MIT. Badge for sharable Twitter link. Pytest PyPI version

Installation

To install the package locally use the following:

pip install get-loggy

Features

  • Color support
  • Custom color support (advanced)
  • Add additional logging levels
  • Optional log stream vs. log file
  • Log record format
  • Package level logging

Usage

Loggy exists as a simple interface for some standard logging in Python. This is done at the package level, not by name.

Basic instantiation

A basic logger may look like this, defaulting to the "info" level logging.

from loggy import loggy

log = loggy.get_loggy()

log.info("Something")
>>> 2022-06-21 20:16:39 PM PDT | INFO | Something | (<stdin>:1:<module>) |

Using color

Colors are supported as well, though not for use with log files. Color and log files are mutually exclusive, as the color codes would clutter the logs.

log = loggy.get_loggy(use_color=True)

Writing to files

File handlers are initiated using a dictionary of configurations for the file, this gives more granular control over file based logging. This is passed directly to the FileHandler() instantiation.

The below example creates a log file with append mode.

file_config = {"filename": "some-log-file.log", "mode": "a"}
log = loggy.get_loggy(log_file=file_config)

Advanced usage

Custom colors can be created or added along with custom logging levels. See the conftest.py for an example of custom formatter and 'test_loggy.py' to see how the colors are added for a custom logging level.

Running tests

Pytest is used as the test runner. To install and run tests use the requirements-dev.txt and execute with pytest.

Note: Use a virtual environment. The steps to create one are left to the user, there are many packages that accomplish this.

pip install -r requirements-dev.txt
pytest

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

get-loggy-0.0.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

get_loggy-0.0.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file get-loggy-0.0.5.tar.gz.

File metadata

  • Download URL: get-loggy-0.0.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for get-loggy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1817d5d6de8130ed05e0732b52f3168519664e13bf009fa542dc67a2fdbee5ba
MD5 e095af90d0938f1794a8d3cdd98cec24
BLAKE2b-256 eb65f86dcd3bfb61d059e913f1283d25d1c5e2636a41bb9c09a29c986015642c

See more details on using hashes here.

File details

Details for the file get_loggy-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: get_loggy-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for get_loggy-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d67e52f7ee2efa612a907a0e2905d0e8952862c9f5f28d1f404c20c606c34ced
MD5 5e0d203415b02f5deae3f987d360b1d7
BLAKE2b-256 264df6cdf68d71b69b27bf6f14bbf79959cc258c8c48a503c128f6c46fa07f15

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