Skip to main content

A python logger similair to the lavavel logs. Made for internal use in Appcomm.

Project description

Appcomm Python Logger

This package provides a custom logging solution with colorized output for the terminal and detailed logs saved to a file. It is designed to handle log messages at different severity levels (DEBUG, INFO, WARNING, ERROR, and CRITICAL) and to log exception details with tracebacks for better debugging.

Features

  • Colorized Console Output: Logs are colorized for easy identification based on their severity (e.g., green for INFO, red for ERROR).
  • Log File: All log messages are saved in log file, with detailed timestamps and log levels.
  • Exception Handling: Supports logging exception details, including full tracebacks, making it easier to diagnose issues.
  • Customizable Directory: The directory for log files can be customized, with a default of ./logs.

Installation

To install the Appcomm_python_Logger package, you can simply copy the logger class into your project or install it via a package manager if it has been uploaded to PyPI.

pip install Appcomm_python_Logger

Usage

To use the logger, you can import the Logger class and create an instance of it in your code. You can then log messages at different severity levels using the debug(), info(), warning(), error(), and critical() methods.

from Appcomm_python_Logger import Logger

logger = Logger()

logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warning("This is a warning message.")
logger.error("This is an error message.")
logger.critical("This is a critical message.")

Logging with Exceptions

To log an exception with a traceback, use the exc argument:

try:
    # Simulate an operation that raises an exception
    raise Exception("Failed to connect to the SFTP server")
except Exception as e:
    logger.error("An error occurred while connecting to the SFTP server", exc=e)

Customizing the Log File Directory

By default, log messages are displayed in the terminal with colorized output and saved to a log file in the ./logs directory. You can customize the log file directory by passing a log_dir argument to the Logger class.

logger = Logger(log_dir="./my_logs")

Author

This logger package was created by Furkan Öztürk (https://furkanozturk.nl/), intern for Appcomm (https://appcomm.nl).

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

appcomm_python_logger-0.0.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

Appcomm_python_Logger-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file appcomm_python_logger-0.0.2.tar.gz.

File metadata

  • Download URL: appcomm_python_logger-0.0.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.5

File hashes

Hashes for appcomm_python_logger-0.0.2.tar.gz
Algorithm Hash digest
SHA256 941eb9c06ee1f793687179f9cbba49ace334b64a82458968c3bbb02f621f42b8
MD5 3de32bd344035881345e44967060eb96
BLAKE2b-256 68ce0e79fb87d19951b98cca46dd222f27c1dc619750adcf3eb134a89f306f47

See more details on using hashes here.

File details

Details for the file Appcomm_python_Logger-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for Appcomm_python_Logger-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f1423e04817b73d6c69ba49f3fb2fc25c350e401070e13f3e5f85a3d3f8ea91
MD5 e229a17d5c96365670a4825a43a34da6
BLAKE2b-256 140237d5b804ff0652518f216ae3e0785ddd797e962c814dbb67b8c19be6ff94

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