From b7216dac6941cf859169743f28394df88c843634 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 14 2020 20:19:09 +0000 Subject: [PATCH 1/2] Adjust the default configuration file to increase the logging We need to have the pagure logger in DEBUG mode and have them go to the terminal so that we can see the email which are being printed there (instead of being sent). Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/files/pagure.cfg b/dev/ansible/roles/pagure-dev/files/pagure.cfg index 60e724f..b80af6f 100644 --- a/dev/ansible/roles/pagure-dev/files/pagure.cfg +++ b/dev/ansible/roles/pagure-dev/files/pagure.cfg @@ -1,6 +1,9 @@ import os from datetime import timedelta +from pagure.mail_logging import ContextInjector + + ### Set the time after which the admin session expires # There are two sessions on pagure, login that holds for 31 days and # the session defined here after which an user has to re-login. @@ -166,3 +169,48 @@ APPLICATION_ROOT = '/' # was running since before version 1.3 and if you care about backward # compatibility in your URLs. OLD_VIEW_COMMIT_ENABLED = False + + +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "standard": { + "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s" + }, + }, + "filters": {"myfilter": {"()": ContextInjector}}, + "handlers": { + "console": { + "formatter": "standard", + "class": "logging.StreamHandler", + "stream": "ext://sys.stdout", + }, + }, + # The root logger configuration; this is a catch-all configuration + # that applies to all log messages not handled by a different logger + "root": {"handlers": ["console"]}, + "loggers": { + "pagure": { + "handlers": ["console"], + "level": "DEBUG", + "propagate": True, + }, + "flask": { + "handlers": ["console"], + "level": "INFO", + "propagate": False, + }, + "sqlalchemy": { + "handlers": ["console"], + "level": "WARN", + "propagate": False, + }, + "pagure.lib.encoding_utils": { + "handlers": ["console"], + "level": "WARN", + "propagate": False, + }, + }, +} + From a0401684d24ae3f76852d9187be5cef72bbd2502 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 14 2020 20:21:17 +0000 Subject: [PATCH 2/2] Add a plog alias and adjust the motd displayed when logging in Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/files/bashrc b/dev/ansible/roles/pagure-dev/files/bashrc index 5185a05..28f45f1 100644 --- a/dev/ansible/roles/pagure-dev/files/bashrc +++ b/dev/ansible/roles/pagure-dev/files/bashrc @@ -41,3 +41,5 @@ pstatus (){ systemctl --user status pagure.service pagure-docs.service pagure_ci.service\ pagure_ev.service pagure_webhook.service pagure_worker.service } + +alias plog="journalctl --user -lu pagure.service" diff --git a/dev/ansible/roles/pagure-dev/files/motd b/dev/ansible/roles/pagure-dev/files/motd index 15a6ae7..53abeee 100644 --- a/dev/ansible/roles/pagure-dev/files/motd +++ b/dev/ansible/roles/pagure-dev/files/motd @@ -10,14 +10,20 @@ Here are some tips: * You can populate the database with `python dev-data.py --all` -* Run `pstart` to start the development server and `pstop` to stop it. - * Logs for the server are available with `journalctl`; the services are run as systemd user units in ~/.config/systemd/user/ * To run the tests you need python3 virtualenv: `workon python3-pagure`. Then you can run them with `./runtests.py run`. +Here is a list of command and alias you may find useful: + +* pstart: to start all the services +* pstop: to stop all the services +* prestart: to restart all the services +* plog: to access the logs of the `pagure` service (the web server) + + Once you start the server you can navigate to http://localhost:5000/ in your browser on the host to access your Pagure development environment.