Skip to main content

Easily Launch Logging (el_logging)

Loguru based custom logging package for simple python projects.

Features

  • Loguru based logging - https://pypi.org/project/loguru
  • Custom basic logging module
  • Logging to files (all, error, json)
  • Custom logging formats
  • Custom options as a config
  • Colorful logging
  • Multiprocess compatibility (Linux, macOS - 'fork', Windows - 'spawn')

Installation

1. Prerequisites

  • Python (>= v3.7)
  • PyPi (>= v21)

2. Install el-logging

# Install or upgrade el-logging package:
pip install --upgrade el-logging

# To uninstall package:
pip uninstall -y el-logging
# Clone repository by git:
git clone git@bitbucket.org:ellexiinc/el_logging.git
cd el_logging

# Install python dependencies:
pip install --upgrade pip
cat requirements.txt | xargs -n 1 -L 1 pip install --no-cache-dir

# Add current path to PYTHONPATH:
export PYTHONPATH="${PWD}:${PYTHONPATH}"
# Clone repository by git:
git clone git@bitbucket.org:ellexiinc/el_logging.git
cd el_logging

# Building python package:
pip install --upgrade pip setuptools wheel
python setup.py build
# Install python dependencies with built package to current python environment:
python setup.py install --record installed_files.txt

# To remove only installed el-logging package:
head -n 1 installed_files.txt | xargs rm -vrf
# Or to remove all installed files and packages:
cat installed_files.txt | xargs rm -vrf

3. Configuration (You can skip this step, if you don't want to configure)

cp -v .env.example [PROJECT_DIR]/.env
cd [PROJECT_DIR]
nano .env
mkdir -vp [PROJECT_DIR]/configs

cp -v logger.yaml [PROJECT_DIR]/configs/logger.yaml
rm -vf logger.yaml
cd [PROJECT_DIR]
nano configs/logger.yaml

Usage/Examples

from el_logging import logger


logger.trace('Tracing...')
logger.debug('Debugging...')
logger.info('Logging info.')
logger.success('Success.')
logger.warning('Warning something.')
logger.error('Error occured.')
logger.critical('CRITICAL ERROR.')


def divide(a, b):
    _result = a / b
    return _result

try:
    divide(10, 0)
except Exception as err:
    logger.exception("Failed to divide:")

Running Tests

To run tests, run the following command:

python -m unittest tests/test_*.py

Environment Variables

You can use the following environment variables inside .env file:

ENV=development
DEBUG=true
APP_NAME=tsc_vrae
LOGS_DIR="/var/log/app"

Configuration

You can use the following sample configuration:

logger:
    level: "INFO"
    use_color: true
    use_icon: false
    use_backtrace: true
    std_format_str: "[<c>{time:YYYY-MM-DD HH:mm:ss.SSS Z}</c> | <level>{lvlname:<5}</level> | <w>{file}</w>:<w>{line}</w>]: <level>{message}</level>"
    use_log_file: false
    file_format_str: "[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {lvlname:<5} | {file}:{line}]: {message}"
    rotate_when:
        at_hour: 0
        at_minute: 0
        at_second: 0
    rotate_file_size: 10000000
    backup_file_count: 50
    file_encoding: utf8
    all_log_filename: "{app_name}.std.all.log"
    err_log_filename: "{app_name}.std.err.log"
    use_log_json: false
    use_custom_json: false
    json_all_log_filename: "{app_name}.json.all.log"
    json_err_log_filename: "{app_name}.json.err.log"
    # logs_dir: /var/log/app

References

Metadata

Release files for el-logging 0.2.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for el-logging 0.2.28
File Size Uploaded Provenance Actions
el_logging-0.2.28.tar.gz 6.3 kB Without provenance Details for el_logging-0.2.28.tar.gz

Release files / el_logging-0.2.28.tar.gz

Download URL el_logging-0.2.28.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d223f251340eb2bb6dd3f6ae7cf3a1d24a9533353a51ae7ff63526200d1dd9f5
BLAKE2b-256 checksum
How to use checksums
841959b60e69b07f7fec1f251d6c82a465ee83701a52afa1d2415f5f03b71899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

Security for el-logging 0.2.28

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page