From cb30bbbd88c6c483d329185240c4fd261dbd06bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Mon, 31 Jan 2022 19:39:01 +0100
Subject: [PATCH 2/8] general: remove tracing logs (#61292)

---
 wcs/admin/forms.py           |  6 +-----
 wcs/admin/workflows.py       |  7 +------
 wcs/backoffice/management.py |  6 +-----
 wcs/forms/common.py          |  9 +--------
 wcs/forms/root.py            | 10 +---------
 wcs/root.py                  |  6 +-----
 6 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/wcs/admin/forms.py b/wcs/admin/forms.py
index d91d2a3ac..281ed6056 100644
--- a/wcs/admin/forms.py
+++ b/wcs/admin/forms.py
@@ -29,7 +29,7 @@ from wcs.carddef import CardDef
 from wcs.categories import Category
 from wcs.formdef import DRAFTS_DEFAULT_LIFESPAN, FormDef, FormdefImportError, FormdefImportRecoverableError
 from wcs.forms.root import qrcode
-from wcs.qommon import _, force_str, get_logger, misc, template
+from wcs.qommon import _, force_str, misc, template
 from wcs.qommon.afterjobs import AfterJob
 from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.errors import AccessForbiddenError, TraversalError
@@ -1121,10 +1121,6 @@ class FormDefPage(Directory):
             return self.workflow_status_remapping_submit(form, new_workflow)
 
     def workflow_status_remapping_submit(self, form, new_workflow):
-        get_logger().info(
-            'admin - form "%s", workflow is now "%s" (was "%s")'
-            % (self.formdef.name, new_workflow.name, self.formdef.workflow.name)
-        )
         status_mapping = {}
         for status in self.formdef.workflow.possible_status:
             status_mapping[status.id] = form.get_widget('mapping-%s' % status.id).parse()
diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py
index 011b00d4d..4a0cec388 100644
--- a/wcs/admin/workflows.py
+++ b/wcs/admin/workflows.py
@@ -32,7 +32,7 @@ from wcs.carddef import CardDef
 from wcs.categories import WorkflowCategory
 from wcs.formdata import Evolution
 from wcs.formdef import FormDef
-from wcs.qommon import _, errors, force_str, get_logger, misc, template
+from wcs.qommon import _, errors, force_str, misc, template
 from wcs.qommon.admin.menu import command_icon
 from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.form import (
@@ -796,11 +796,6 @@ class WorkflowStatusPage(Directory):
                             modified = True
                     if modified:
                         item.store()
-        if action == 'remove':
-            get_logger().info(
-                'admin - delete status "%s" in workflow "%s": %d forms deleted'
-                % (self.status.name, self.workflow.name, nb_forms)
-            )
 
     def display(self):
         form = Form(enctype='multipart/form-data')
diff --git a/wcs/backoffice/management.py b/wcs/backoffice/management.py
index 947896eac..8cf6926f4 100644
--- a/wcs/backoffice/management.py
+++ b/wcs/backoffice/management.py
@@ -45,7 +45,7 @@ from wcs.roles import logged_users_role
 from wcs.variables import LazyFieldVar
 from wcs.workflows import ActionsTracingEvolutionPart, WorkflowStatusItem, item_classes, template_on_formdata
 
-from ..qommon import _, errors, ezt, force_str, get_cfg, get_logger, misc, ngettext, ods
+from ..qommon import _, errors, ezt, force_str, get_cfg, misc, ngettext, ods
 from ..qommon.afterjobs import AfterJob
 from ..qommon.backoffice.listing import pagination_links
 from ..qommon.backoffice.menu import html_top
@@ -1863,7 +1863,6 @@ class FormPage(Directory):
     def _q_index(self):
         self.view_type = 'table'
         self.check_access()
-        get_logger().info('backoffice - form %s - listing' % self.formdef.name)
 
         if 'job' in get_request().form:
             return self.job_multi()
@@ -2041,8 +2040,6 @@ class FormPage(Directory):
         order_by = misc.get_order_by_or_400(get_request().form.get('order_by', None))
         skip_header_line = bool(get_request().form.get('skip_header_line'))
 
-        get_logger().info('backoffice - form %s - listing csv' % self.formdef.name)
-
         count = self.formdef.data_class().count()
         job = CsvExportAfterJob(
             self.formdef,
@@ -2354,7 +2351,6 @@ class FormPage(Directory):
             'statistics', get_request().user
         ):
             raise errors.AccessForbiddenError()
-        get_logger().info('backoffice - form %s - stats' % self.formdef.name)
         html_top('management', '%s - %s' % (_('Form'), self.formdef.name))
         r = TemplateIO(html=True)
         get_response().breadcrumb.append(('stats', _('Statistics')))
diff --git a/wcs/forms/common.py b/wcs/forms/common.py
index f82b6a6b5..c987e1bb1 100644
--- a/wcs/forms/common.py
+++ b/wcs/forms/common.py
@@ -30,7 +30,7 @@ from wcs.blocks import BlockSubWidget, BlockWidget
 from wcs.qommon.admin.texts import TextsDirectory
 from wcs.workflows import EditableWorkflowStatusItem, RedisplayFormException
 
-from ..qommon import _, errors, get_logger, misc, template
+from ..qommon import _, errors, misc, template
 
 
 class FileDirectory(Directory):
@@ -254,7 +254,6 @@ class FormStatusPage(Directory, FormTemplateMixin):
                 return redirect(self.filled.get_url(backoffice=True))
 
         get_request().view_name = 'status'
-        get_logger().info('form %s - id: %s - view' % (self.formdef.name, self.filled.id))
 
         user = get_request().user
         form = self.get_workflow_form(user)
@@ -577,7 +576,6 @@ class FormStatusPage(Directory, FormTemplateMixin):
                 get_session().unmark_visited_object(self.filled)
                 return response
 
-        get_logger().info('form %s - id: %s - view status' % (self.formdef.name, self.filled.id))
         get_response().add_javascript(['jquery.js', 'qommon.forms.js'])
         self.html_top('%s - %s' % (self.formdef.name, self.filled.id))
         r = TemplateIO(html=True)
@@ -656,17 +654,12 @@ class FormStatusPage(Directory, FormTemplateMixin):
         return r.getvalue()
 
     def submit(self, form):
-        current_status = self.filled.status
         user = get_request().user
         next_url = self.filled.handle_workflow_form(user, form)
         if next_url:
             return next_url
         if form.has_errors():
             return
-        if current_status != self.filled.status:
-            get_logger().info(
-                'form %s - id: %s - status -> %s' % (self.formdef.name, self.filled.id, self.filled.status)
-            )
         try:
             self.check_auth()
         except errors.AccessError:
diff --git a/wcs/forms/root.py b/wcs/forms/root.py
index 289e7d343..87fc830f1 100644
--- a/wcs/forms/root.py
+++ b/wcs/forms/root.py
@@ -45,7 +45,7 @@ from wcs.roles import logged_users_role
 from wcs.variables import LazyFormDef
 from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowStatusItem
 
-from ..qommon import _, emails, errors, get_cfg, get_logger, misc, template
+from ..qommon import _, emails, errors, get_cfg, misc, template
 from ..qommon.admin.emails import EmailsDirectory
 from ..qommon.form import CheckboxWidget, EmailWidget, Form, HiddenErrorWidget, HtmlWidget, StringWidget
 from ..qommon.template import TemplateError
@@ -288,8 +288,6 @@ class FormPage(Directory, FormTemplateMixin):
         return 0
 
     def step(self, step_no, current_page):
-        get_logger().info('form %s - step %s' % (self.formdef.name, step_no))
-
         page_labels = []
         current_position = 1
 
@@ -1015,7 +1013,6 @@ class FormPage(Directory, FormTemplateMixin):
             return self.page(self.pages[0])
 
         if form.get_submit() == 'cancel':
-            get_logger().info('form %s - cancel' % (self.formdef.name))
             if self.edit_mode:
                 return redirect('.')
             magictoken = form.get_widget('magictoken').parse()
@@ -1139,7 +1136,6 @@ class FormPage(Directory, FormTemplateMixin):
             if get_request().form.get('f00'):  # 🍯
                 form.add(HiddenErrorWidget, 'honeypot')
                 form.set_error('honeypot', 'error')
-                get_logger().info('form %s - honeypot was touched' % self.formdef.name)
                 page_error_messages.append(_('Honey pot should be left untouched.'))
 
             # form.get_submit() returns the name of the clicked button, and
@@ -1451,8 +1447,6 @@ class FormPage(Directory, FormTemplateMixin):
             get_session().store()
         self.set_tracking_code(filled, data)
 
-        get_logger().info('form %s - saving draft (id: %s)' % (self.formdef.name, filled.id))
-
         return filled
 
     def get_current_draft(self):
@@ -1534,7 +1528,6 @@ class FormPage(Directory, FormTemplateMixin):
         self.set_tracking_code(filled)
         session.remove_magictoken(get_request().form.get('magictoken'))
 
-        get_logger().info('form %s - done (id: %s)' % (self.formdef.name, filled.id))
         url = None
         if existing_formdata is None:
             self.clean_submission_context()
@@ -1797,7 +1790,6 @@ class RootDirectory(AccessControlled, Directory):
         user = request.user
 
         if not self.category:
-            get_logger().info('home page')
             if user:
                 message = TextsDirectory.get_html_text('welcome-logged')
             else:
diff --git a/wcs/root.py b/wcs/root.py
index 09c7cd0ab..94635efcd 100644
--- a/wcs/root.py
+++ b/wcs/root.py
@@ -33,7 +33,7 @@ from .forms import root
 from .forms.actions import ActionsDirectory
 from .forms.preview import PreviewDirectory
 from .myspace import MyspaceDirectory
-from .qommon import _, errors, get_cfg, get_logger, ident, misc, saml2, template
+from .qommon import _, errors, get_cfg, ident, misc, saml2, template
 from .qommon.afterjobs import AfterJobStatusDirectory
 from .qommon.form import Form, RadiobuttonsWidget
 from .qommon.pages import PagesDirectory
@@ -60,14 +60,12 @@ class LoginDirectory(Directory):
     _q_exports = ['']
 
     def _q_index(self):
-        get_logger().info('login')
         ident_methods = get_cfg('identification', {}).get('methods', [])
 
         if get_request().form.get('ReturnUrl'):
             get_request().form['next'] = get_request().form.pop('ReturnUrl')
 
         if len(ident_methods) == 0:
-            get_logger().info('no ident method defined')
             idps = get_cfg('idp', {})
             if len(idps) == 0:
                 return template.error_page(_('Authentication subsystem is not yet configured.'))
@@ -136,7 +134,6 @@ class RegisterDirectory(Directory):
     _q_exports = ['']
 
     def _q_index(self):
-        get_logger().info('register')
         ident_methods = get_cfg('identification', {}).get('methods', [])
 
         if len(ident_methods) == 0:
@@ -281,7 +278,6 @@ class RootDirectory(Directory):
         return root.auth(get_publisher().get_root_url())
 
     def logout(self):
-        get_logger().info('logout')
         session = get_session()
         if not session:
             return redirect(get_publisher().get_root_url())
-- 
2.34.1

