Skip to main content

Loguru based custom logging package for simple python projects.

Project description

Easily Launch Logging (el_logging)

  • Custom basic logging module
  • Loguru based custom logging package for simple python projects.
  • Logging to files (all, error, json)
  • Custom logging formats
  • Custom options as a configs
  • Colorful logging
  • Multiprocess compatibility (Linux, macOS - 'fork', Windows - 'spawn')

Prerequisites

  • Python (v3.6)
  • PyPi (v21)

Getting started

1. Installation

A. PyPi install (Recommended)

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

## To uninstall package:
pip uninstall -y el-logging

B. Manually add to PYTHONPATH (Recommended for development)

## Clone repository by git
git clone git@bitbucket.org:ellexiinc/elcomm.git

## Install python dependencies
cd el_logging
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"

C. Manually compile and setup (Not recommended)

## Clone repository by git
git clone git@bitbucket.org:ellexiinc/elcomm.git

## Building python package
cd el_logging
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
## To remove all installed files and packages:
cat installed_files.txt | xargs rm -vrf

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

IMPORTANT: First, check .env.example (environment variables) file.

Copy .env.example file to .env and change environment variables:

cp .env.example .env
vi .env

Make configs directory inside project's base directory and copy configs/logger.yaml or configs/logger.json file into configs. Then edit variable options:

mkdir $PROJECT/configs

## For yaml configs
cp configs/logger.yaml $PROJECT/configs/logger.yaml
vi $PROJECT/configs/logger.yaml

## Or json configs
cp configs/logger.json $PROJECT/configs/logger.json
vi $PROJECT/configs/logger.json

3. Import module

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 = 0
    try:
        _result = a / b
    except ZeroDivisionError:
        logger.error("'b' argument value is zero!")
        raise
    return _result

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

References

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

el_logging-0.2.18.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file el_logging-0.2.18.tar.gz.

File metadata

  • Download URL: el_logging-0.2.18.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for el_logging-0.2.18.tar.gz
Algorithm Hash digest
SHA256 4e43089e533300e8e87b16a0e81ffe4d03f31d57eaae2280fc219dc6f2216f10
MD5 58d6748940cacd6b4342e027851465e3
BLAKE2b-256 027d84571b43131e1f1daf00f77db8f030c95c61f10978e3e4d6367d059b817f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page