Coder Social home page Coder Social logo

cermakm / common Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thoth-station/common

0.0 3.0 0.0 1.53 MB

A common library for the Thoth project

Home Page: https://thoth-station.github.io/

License: GNU General Public License v3.0

Python 100.00%

common's Introduction

Thoth Common

A library used in project Thoth. It's aim is to provide core utilities for logger setup, manipulation with datetimes and similar handy helpers.

Installation

This project is released on PyPI, so the latest release can be installed via pip or Pipenv as shown below:

pipenv install thoth-common

This library will automatically discover installed packages and enable Sentry integrations if you use Flask, SQLAlchemy or AIOHTTP. An exception is for Flask applications, that need to explicitly install sentry-sdk[flask] due to integrations dependencies.

Logging setup

To setup a logger in any of Thoth's component (component that are namespaced with thoth), you can simply set an environment variable. The name of environment variable is constructed from module name. Let's say you want to debug thoth.adviser.pipeline module, in that case you can set environment variable:

THOTH_LOG_ADVISER_PIPELINE=DEBUG which will cause loggers thoth.adviser.pipeline to be set to DEBUG mode. See log-levels documentation for more info. If a module has underscore in its name, replace it with double underscore in the environment variable name.

To setup a logger that is not introduced by a Thoth's component, you can set THOTH_ADJUST_LOGGING environment variable. The format of this environment variable THOTH_ADJUST_LOGGING is a comma separated list where each entry is made out of a logger name and a corresponding log-level ("DEBUG", "INFO", "WARNING", "ERROR" as for standard Python's logging). These two are delimited by a colon, an example:

THOTH_ADJUST_LOGGING="flask:WARNING,alembic.migrations:ERROR"

Ignoring reports from a logger

In some cases it's expected to turn off reporting of some logger to Sentry. You can provide THOTH_SENTRY_IGNORE_LOGGER environment variable which holds a comma separated list of loggers that should be ignored when reporting errors to Sentry:

THOTH_SENTRY_IGNORE_LOGGER="thoth.adviser.resolver,thoth.adviser.run"

This is helpful if you want to report errors to users but not to Thoth application itself.

If you want some certain classes of error not to be reported to Sentry, you can can provide THOTH_SENTRY_IGNORE_EXCEPTION environment variable which holds the comma-separated list of exception classes to be ignored when reporting to Sentry:

THOTH_SENTRY_IGNORE_EXCEPTION="connexion.decorators.validation,builtins.ValueError"

Remember all builtin exception classes need to be specified as in the same manner as ValueError is specified above.

common's People

Watchers

 avatar  avatar  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.