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

Uploaded Python 3

File details

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

File metadata

  • Download URL: thcustomlogger-0.1.2.tar.gz
  • Upload date:
  • Size: 8.2 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.2.tar.gz
Algorithm Hash digest
SHA256 a50878976f398df292b63d3b8937e52445ee1dc33643b9339095c9eb03a120c7
MD5 0c2e7fc828ee1f4bed957dbdb4fab564
BLAKE2b-256 bf3e51a4513ae7a72559fd4d16ec2c47977f12ea23e468fada22d8fdac1d43d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thcustomlogger-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2595921ed39d4701d071a3eb0eba8cb0a7908fa2080fa189b8282fc9d2cc5605
MD5 0e064df86652bc022e4530544b4d844c
BLAKE2b-256 346ad006c1a07f13843d5b6d7eb0aaf755ea9c849524db8902661739b936bf70

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