Skip to main content

A custom logging package with multiline formatting

Project description

THCustomLogger

A simple, reusable logger setup to use across projects. Automatically configures setup for log and console.

Table of Contents

Installation

pip install THCustomLogger

Quick Start

from THCustomLogger import setup_logger, get_commit_hash

# Use the logger
logger.info("This is an info message")
logger.debug("This is a debug message")

# Get the current git commit hash
commit = get_commit_hash()
logger.info(f"Current commit: {commit}")

Features

  • Creates a logger instance, directory, and log file
  • Custom logging setup with predefined formatting
  • Multi-line formatting
  • Prints color to console
  • Git commit hash integration to track versions

Configuration

Basic Configuration

  • None at this time

Advanced Settings

  • None at this time

Usage Examples

Basic Logging

logger.info(f"Done.", extra={'msg_break': '*'})
logger.info(f"Done.\n----------", extra={'no_indent': True})
logger.info(f"Done.\nfffffffffff", extra={'msg_break': '/', 'no_indent': True})

logger.debug('debug message')
logger.info('hello world')
logger.warning('Oh No')
logger.error('Error')
logger.critical('Critical')
logger.info(f"Commit hash: {get_commit_hash()}\nLatest tag:")
2025-04-12 20:19:40.493 | Line: 118 logger_setup.main                 | INFO    : Done.
**********************************************************************************
2025-04-12 20:19:40.493 | Line: 119 logger_setup.main                 | INFO    : Done.
----------
2025-04-12 20:19:40.493 | Line: 120 logger_setup.main                 | INFO    : Done.
fffffffffff
//////////////////////////////////////////////////////////////////////////////////
2025-04-12 20:19:40.493 | Line: 122 logger_setup.main                 | DEBUG   : debug message
2025-04-12 20:19:40.493 | Line: 123 logger_setup.main                 | INFO    : hello world
2025-04-12 20:19:40.493 | Line: 124 logger_setup.main                 | WARNING : Oh No
2025-04-12 20:19:40.493 | Line: 125 logger_setup.main                 | ERROR   : Error
2025-04-12 20:19:40.493 | Line: 126 logger_setup.main                 | CRITICAL: Critical
2025-04-12 20:19:40.507 | Line: 127 logger_setup.main                 | INFO    : Commit hash: f633ac2edf0e15e8a1507b5371de653d21b9ded2
                                                                                  Latest tag:
2025-04-12 20:19:40.507 | Line: 134 logger_setup.example              | ERROR   : division by zero
Traceback (most recent call last):
  File "/CustomLogger/src/THCustomLogger/logger_setup.py", line 132, in example
    1 / 0
    ~~^~~
ZeroDivisionError: division by zero

Advanced Usage

[Add advanced usage examples]

API Reference

setup_logger()

[Document parameters and return values]

get_commit_hash()

[Document functionality and usage]

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Copyright (c) 2025 Tyler Haunreiter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

thcustomlogger-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

thcustomlogger-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for thcustomlogger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fa5a19fc0d8caee5d9c0e45a76e7c4f1609b0fd64741768797a86fa8653a8c2f
MD5 521ec436ba9d64d8dfcb76e2d2be4b05
BLAKE2b-256 19beccc90d2d2cbcd31c97dcd7a0710200db4e42f69430b836f121e80a919efa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thcustomlogger-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for thcustomlogger-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1964069a62b9c2258085bd567ef1d10d7dc87a2d148cb5c031560d848bf70c4
MD5 4f4f33704d9d61e7ddfd5b06dbc717b8
BLAKE2b-256 499b0942efa980d1d41dc03ab23b84302b282c3c6d41878c848be8d25b98dd59

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