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.3.tar.gz (8.6 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.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thcustomlogger-0.1.3.tar.gz
  • Upload date:
  • Size: 8.6 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.3.tar.gz
Algorithm Hash digest
SHA256 52ed5c792b7e9ff79c50ffce53009084e0b64941fff54cbc54b283730df9ac2d
MD5 87f36283c94b2518aeea5399dbe609a0
BLAKE2b-256 e59565107e91caeb8e8a6e17b168a16b24fe8d5d6d8ad954091c7cd24c46802a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thcustomlogger-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4bc871bdd9584b653d43e734e5fe69c61e142fb19e53e9c4eec5ca9988f21713
MD5 5209d260396b1676976c29bbd1bd9cac
BLAKE2b-256 a11d96d05dab903d1a52e26787e6a587342b065dbe4cf3c06585f81caacd2376

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