Skip to main content

A fast 'read to use' Logging system which provides stdout/file/custom stream with easy syntax and operation. It's a very simple approach of Laravel drivers sorts, by the way, handlers ands drivers are both the same

Project description

codecov

Escriba Logger Logo

Get Started

install

python -m pip install EscribaLogger

Usage

Just import, add drivers and use:

You can output your logs using a pre-configured builtin rich stdout handler

from EscribaLogger import Log

# Initilize
Log()
Log.set_logger_name('CustomName')

# Add drivers (stdout, file, graylog, flutend etc)
Log.add_driver('stdout')

Log.info('My info message', {'context_var': 'value'})
# > [01/12/25 20:30:20] INFO     CustomName - My info message                                                                <stdin>:1

Log file driver

# You can add another driver. In this case, we will add the file driver
Log.add_driver('file')


Log.info('Some message', extra={"context_var": "value"})
# > The message will be stored in "logs/2023-07-16.log"
# > [2023-07-16 16:13:55,100] EscribaLogger.INFO - Some message - {"context_var": "value"}

In the default logging system, handle context variables is a exhausting task. EscribaLogger added the "extra_context" log variable to solve this. You add the context info for any custom driver.

Change default log files storage

# You can change default path to store log files in:
Log.add_driver('file', driver_option={'file_location': 'another/path'})


Log.info('Some message', extra={"context_var": "value"})
# > The message will be stored in "another/path/2023-07-16.log"
# > [2023-07-16 16:13:55,100] EscribaLogger.INFO - Some message - {"context_var": "value"}

Contributing

Setup env

  1. install pdm
python -m pip install pdm
  1. install dependencies
pdm install

Tests

We are using pytest and coverage.py to maintain this project. You can run the tests by using:

pdm run test:unit

the command above will generate the .coverage file in root path. Now you can generate the coverage report

Coverage

coverage report -m

Or you can create a entire webpage to see the results:

pdm run coverage html

Supported by

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