Metadata-Version: 2.0
Name: thoth-common
Version: 0.9.17
Summary: Shared code logic in the project Thoth.
Home-page: UNKNOWN
Author: Fridolin Pokorny
Author-email: fridolin@redhat.com
License: GPLv3+
Description-Content-Type: UNKNOWN
Platform: UNKNOWN
Requires-Dist: attrdict
Requires-Dist: daiquiri
Requires-Dist: sentry-sdk
Requires-Dist: requests
Requires-Dist: rfc5424-logging-handler
Requires-Dist: attrs
Requires-Dist: pyyaml
Requires-Dist: requests
Requires-Dist: openshift
Requires-Dist: argo-workflows

Thoth Common
------------

A library used in project `Thoth <https://thoth-station.ninja>`_. 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 <https://pypi.org/project/thoth-common>`_, so the latest release can be
installed via pip or `Pipenv <https://pipenv.readthedocs.io>`_ as shown below:

.. code-block:: console

  pipenv install thoth-common

This library will automatically discover installed packages and enable `Sentry
integrations <https://docs.sentry.io/platforms/python/>`_ 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 <https://docs.python.org/3/library/logging.html#logging-levels>`_
for more info. If a module has underscore in its name, replace it with double
underscore in the environment variable name.

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:

.. code-block:: console

  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.



