-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Control Logging level via ENV variable #107
Comments
I've tried to look into this as I need some ENV vars for my attempt to implement coverage. I've started with something like this in # Options are: prod, dev, debug (default), test (for coverage)
APP_ENV = os.getenv("APP_ENV", "debug")
ENV_LOG_FLAG = True
if APP_ENV in ["test", "prod"]:
ENV_LOG_FLAG = False and so I could address engine = create_engine(application.config["SQLALCHEMY_DATABASE_URI"], echo=ENV_LOG_FLAG) So, doing But now I'm confused because ...
from logzero import logger
...
logger.debug("Autocomplete query '%s' and query type '%s'", query, query_type)
... And everywhere else I see e.g.: application.logger.info("Delete session") With if APP_ENV == 'prod':
# Set a minimum log level
logzero.loglevel(logging.ERROR) But how would it work with All that said, I have no idea how is it in AWS production servers. |
I started to put in logzero and then I learned about flask integrated logs so I stopped that. Thus logzero stuff is my legacy (ie: trash), it can be replaced by the In order to configure logs with your variable you need to touch the method
Also, I see in your code that you are using all big case variable names. I think the convention is to use that only for constants. Not sure if that is PEP8 or not. While the environment variables are normally all big case, the python variables where you store their value should not. That said I don't care much about this, but the checks in place may complain. |
I will go ahead then, retiring |
* For using coverage with APP_ENV test * Typo * Reorganised * Pytest to print which APP_ENV is being used * To make it work with coverage * Using APP_ENV to define ENV_LOG_FLAG (partially #107) * Skip F811 check * Updated with coverage info * Install process-tests * Fixed docker-compose arg position * Use coverage rather test for APP_ENV * Using gunicorn
I did check https://www.python.org/dev/peps/pep-0008/#constants and the whole thing is, for me,
it can also be defined by |
* Removed logzero * Control Logging level via APP_ENV variable #107
Add
ENV_LOG_TYPE
to handle control levels.e.g.
INFO
(or evenDEBUG
) by default and thenERROR
whenENV_LOG_TYPE=production
?Also use this ENV to control the
echo
value when creating postgres enginehttps://github.com/phenopolis/phenopolis_api/blob/e53e1d789efee43eb5f2e085a19adb6bbe9a07f3/views/postgres.py#L28
The text was updated successfully, but these errors were encountered: