Skip to main content

This library standardizes logs and exceptions, ensuring consistent error handling and tracking.

Project description

Dkr Log

This Python library is designed to standardize all logs_exceptions that a Python application may encounter. By implementing a uniform logging system, it ensures consistency in how errors are displayed in the terminal and recorded in an external database. Not only does it enhance readability and debugging efficiency, but it also provides structured error tracking for improved application maintenance.


Installation

pip install dkrlog

Configuration

Before using this library, it is necessary to define specific environment variables that facilitate logging and error tracking:

  • LOGGER_URL: The URL to which logs will be sent.
  • LOGGER_TOKEN: The authentication token used in API requests.
  • LOGGER_APP_NAME: The name by which the application will be identified in the destination database.

Additionally, the following function must be executed at the beginning of the code to set up the execution ID, as it will be used in all log entries:

def set_vars(exec_id: str):
    ''' Define the execution ID '''
    global EXEC_ID

    EXEC_ID = exec_id

This execution ID must be populated with a unique identifier at the start of the program, ensuring that all logs maintain consistency throughout the application's lifecycle.

Usage

from dkrlog import log_exception, log, set_vars, set_logfile, get_date

# Initialize the execution ID at the beginning of your script
set_vars("your_execution_id")

# Set up a log file (optional but recommended)
set_logfile("execution_log")

# == Logging messages and exceptions ==

# Standard log message:
log("This is an informational message", type="i")

# Logging exceptions within a try-except block:
try:
    # Some operation that may fail
    result = 10 / 0
except Exception as e:
    log_exception("An error occurred while processing", e)

# By following these steps, all logs will be properly recorded in the terminal, saved to log files, and sent to the external logging API

License

This project is licensed under the MIT License.

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

dkrlog-1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

dkrlog-1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file dkrlog-1.0.tar.gz.

File metadata

  • Download URL: dkrlog-1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dkrlog-1.0.tar.gz
Algorithm Hash digest
SHA256 50a12dc7bc8687f7501fbf92671ecabe7887f666bd9e8ca984638ec736b23ba2
MD5 6677eaf07c793c59ee2d8de7723928dc
BLAKE2b-256 396688a6b1cd64765fce1038cda6e165b9d659b98c51aaf2289c249a3ef3f240

See more details on using hashes here.

File details

Details for the file dkrlog-1.0-py3-none-any.whl.

File metadata

  • Download URL: dkrlog-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dkrlog-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1eee28659ded0f1966c335590089cb6c47cbf73ea748ea7523d0eabd3793bb1e
MD5 f1e8ae40b7836acc6967cf4d69518a30
BLAKE2b-256 ddf11d408eee7cd11cf52747c5f82f15fc8a82164c39022dea36c7b169cc3ef7

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