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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file appcomm_python_logger-1.tar.gz.
File metadata
- Download URL: appcomm_python_logger-1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70cab6646cad36ea3c8c52b00ba56915c7054bb6fafa9dca73420202fa04adce
|
|
| MD5 |
7400b3e5a67d3f67d1d397a52342c37f
|
|
| BLAKE2b-256 |
c9be73f88288d4db9183331cd52ab1b2e1f814336115959ec962cb17cb319206
|
File details
Details for the file Appcomm_python_Logger-1-py3-none-any.whl.
File metadata
- Download URL: Appcomm_python_Logger-1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f5ef48124f08828227c08ef33bd97b11165a5e0eabfca0711dd8618d1ba5a90
|
|
| MD5 |
3832434e166d769785fdd22e6d919d26
|
|
| BLAKE2b-256 |
2a2ddd777d4a98efc1ba37bed00beb42a17bde97b5155ebc8628e8ea0fa82517
|