permitio / opal-fetcher-postgres

An OPAL custom data fetcher to bring authorization state from Postgres
https://opal.ac
Apache License 2.0
20 stars 20 forks source link

How to turn on the logs? #4

Closed hongbo-miao closed 3 years ago

hongbo-miao commented 3 years ago

I saw some code in the provider file.

from opal_common.logger import logger
logger.debug('...')

I also tried to add some

print('...')

However, they never got printed after I docker compose up --build.

How can I turn on the logs? Thanks!

orweis commented 3 years ago

Hi @Hongbo-Miao , Check out the config flags (starting with LOG_) at opal_common/config.py (Also remember to prefix with OPAL_ when defining as env-vars)

You can see that the default log level is INFO

    #  - log level
    LOG_LEVEL = confi.str("LOG_LEVEL", "INFO")

and so only logs equal or higher are logged, debug is below and hence ignored.

hongbo-miao commented 3 years ago

Thanks @orweis , adding OPAL_LOG_LEVEL=DEBUG makes logger.debug('...') works! I am surprised my print('...') logs not print. I guess those logs are not shown by design.

orweis commented 3 years ago

Regarding the print - the server config is to propagate out stderr , and not stdout (you can change print of course see - https://www.systutorials.com/how-to-print-a-line-to-stderr-and-stdout-in-python/)

hongbo-miao commented 3 years ago

Oh I see, thanks for the info, @orweis !

kivo360 commented 2 years ago

Low key, check out loguru. It adds bloat to your project, but you have easy global controls in libraries using the configure, enable and disable commands.