Giter Site home page Giter Site logo

loguricorn's Introduction

loguricorn

A small package for rerouting gunicorn logs to loguru

Example

This package provides a compatible interface for automatically routing gunicorn logs to the popular loguru library.

Usage

Install the package:

pip install loguricorn

Then pass the custom interface to gunicorn at runtime:

gunicorn --logger-class loguricorn.Logger tests.app:app

All log records will now be routed through the default loguru.logger.

Configuration

It's possible to customize the loguru.logger instance before gunicorn initializes itself. Simply add your changes in a configuration file and pass it to gunicorn at runtime:

import sys

from loguru import logger

logger.remove()
logger.add(
    sys.stderr,
    colorize=True,
    format="<green>{time}</green> <level>{message}</level>",
)
gunicorn -c conf.py --logger-class loguricorn.Logger tests.app:app

It's recommended to import any customizations from your main application and use them in the configuration in order to obtain a consistent log record format across the entire execution.

Testing

Testing is done by starting gunicorn in a subprocess with the custom logger enabled and validating that the emitted logs match the expected format.

Install dev dependencies:

poetry install

Run test:

poetry run tox .

Contributing

Check out the issues for items needing attention or submit your own and then:

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

loguricorn's People

Contributors

jmgilman avatar p0lygun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.