Skip to main content

A simple reusable logger setup

Project description

Lewis' Lazy Logger

For when you're too lazy to setup loggers every time.

How to use

  • Install the logger package by running pip install lewis-lazy-logger
  • Import into your logger file like so: from lewis_lazy_logger import simple_logger_setup
  • You can then initialise your logger and pick which options you want to enable:
logger = simple_logger_setup(
    level="info", (default = "debug")
    name="my_app", (default = None)
    use_rich=True, (default = False)
    log_to_file=True, (default = False)
    file_path="test.log", (default = "app.log")
    json_output=False, (default = False)
    max_bytes=10000, (default = 1000000)
    backup_count=5, (default = 3)
)

The available fields are:

  • level: str - The log level you want to log (ie debug, info, etc)
  • name: str - The name of your logger instance
  • use_rich: bool - Make use of the Rich package for 'rich text and beautiful formatting in the terminal' (Overwrites json_output)
  • log_to_file: bool - Write your logs to a log file
  • file_path: str - The file path for your logs
  • json_output: bool - Output logs in json format (Not usable with use_rich = True)
  • max_bytes: int - The maximum file size of your log files
  • backup_count: int - The number of backup log files allowed to be created

Example Output

use_rich = False

[13:02:32] [ERROR] my_app: Division by zero!
Traceback (most recent call last):
  File "E:\Projects\LOGGER_TEST\main.py", line 19, in <module>
    1 / 0
    ~~^~~
ZeroDivisionError: division by zero

use_rich = True

[07/05/25 13:00:44] ERROR    Division by zero!                                           main.py:21
                             ╭─────────── Traceback (most recent call last) ───────────╮
                             │ E:\Projects\LOGGER_TEST\main.py:19 in <module>          │
                             │                                                         │
                             │   16 # logger.error("Oops, something went wrong!")      │
                             │   17                                                    │
                             │   18 try:                                               │
                             │ ❱ 19 │   1 / 0                                          │
                             │   20 except ZeroDivisionError:                          │
                             │   21 │   logger.exception("Division by zero!")          │
                             │   22                                                    │
                             ╰─────────────────────────────────────────────────────────╯
                             ZeroDivisionError: division by zero

json_output = True

{"time": "2025-07-05T13:02:59", "level": "ERROR", "logger": "my_app", "message": "Division by zero!", "exception": "Traceback (most recent call last):\n  File \"E:\\Projects\\LOGGER_TEST\\main.py\", line 19, in <module>\n    1 / 0\n    ~~^~~\nZeroDivisionError: division by zero"}

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

lewis_lazy_logger-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

lewis_lazy_logger-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lewis_lazy_logger-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for lewis_lazy_logger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 22c14eb76f1230da8316f3d60cd3b32bc380ed5daa79000daa29872a74df6447
MD5 4fb66ba80304db6c27c69c5a1ee8b542
BLAKE2b-256 9441201530eaaf769a1967c081f5074ad0848f0dbbdbd16b73d668c807a59b4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lewis_lazy_logger-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7886eb32dbbe312bb8c3b17e7ca2622e220a487eabcb69296215ded549927a2
MD5 96cfd0a7501be6ffababe78df29d449f
BLAKE2b-256 04ff4ea8dddb857adce107fd24bdd4f6ce665f3ae163197a3669ae9f5433eaed

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