Debug.rst 9.64 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.. ==================================================
.. ==================================================
.. ==================================================
.. Header hierarchy
.. ==
..  --
..   ^^
..    ""
..     ;;
..      ,,
..
.. --------------------------------------------used to the update the records specified ------
.. Best Practice T3 reST: https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/WritingReST/CheatSheet.html
..             Reference: https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/WritingReST/Index.html
.. Italic *italic*
.. Bold **bold**
.. Code ``text``
.. External Links: `Bootstrap <http://getbootstrap.com/>`_
.. Add Images:    .. image:: ../Images/a4.jpg
..
..
.. Admonitions
..           .. note::   .. important::     .. tip::     .. warning::
.. Color:   (blue)       (orange)           (green)      (red)
..
.. Definition:
.. some text becomes strong (only one line)
..      description has to indented

.. -*- coding: utf-8 -*- with BOM.

.. include:: Includes.txt


.. _debug:

Debug
=====

.. _QFQ_LOG:

QFQ Log
-------

Setup in :ref:`configuration`

* *qfqLog*

  * Filename where to log QFQ debug and error messages.
  * File is relative to the `<site path>` or absolute (starting with '/').
  * Content: error situations of QFQ and debug, if enabled.

All non SQL related information will be logged to QFQ log file.

.. _SQL_LOG:

SQL Log
-------

Setup in :ref:`configuration`

* *sqlLog*

  * Filename where to log SQL queries and statistical data.
  * File is relative to the `<site path>` or absolute (starting with '/').
  * Content: SQL queries and timestamp, formName/formId, fe_user, success, affected rows, newly created record
    id's and accessed from IP.
  * The global setting can be overwritten by defining `sqlLog` inside of a QFQ tt-content record.


.. _SQL_LOG_MODE:

* *sqlLogMode: all|modify|error|none*

  * *all*: logs every SQL statement.
  * *modify*: logs only statements who might potentially change data.
  * *error*: logs only queries which generate SQL errors.
  * *none*: no query logging at all.
  * The global setting can be overwritten by defining `sqlLogMode` inside of a QFQ tt-content record.

* *showDebugInfo = [yes|no|auto],[download]*

  If active, displays additional information in the Frontend (FE). This is typically helpful during development.

  * *yes*:

    * Form:

      * For every internal link/button, show tooltips with decoded SIP on mouseover.
      * Shows an 'Edit form'-button (wrench symbol) on a form. The link points to the T3 page with the :ref:`form-editor`.

    * Report: Will be configured per tt-content record.

      *debugShowBodyText = 1*

  * *no*: No debug info.

  * *auto*: Depending if there is a Typo3 BE session, set internally:

    * *showDebugInfo = yes*  (BE session exist)
    * *showDebugInfo = no*   (no BE session)

  * *download*:

    * During a download (especially by using wkhtml), temporary files are not deleted automatically. Also the
106
      ``wkhtmltopdf``, ``pdfunite``, ``pdf2img`` command lines will be logged to :ref:`QFQ_LOG`. Use this only to debug problems on download.
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

.. _MAIL_LOG:

MAIL Log
--------

Setup in :ref:`configuration`

* *mailLog*

  * File which `sendEmail` logs sending mail.
  * File is relative to the `<site path>` or absolute (starting with '/').


.. _`mail-log-page`:

Mail Log page (Table MailLog)
-----------------------------

For debugging purposes you may like to add a Mail Log page in the frontend.
127
128
129
130
The following QFQ code could be used for that purpose (put it in a QFQ PageContent element)

Note: If you do not use/have the Ggroup table, then remove the "# Filters" block.
::
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282

    # Page parameters
    1.sql = SELECT @grId := '{{grId:C0:digit}}' AS _grId
    2.sql = SELECT @summary := IF('{{summary:CE:alnumx}}' = 'true', 'true', 'false') AS _s

    # Filters
    10 {
      sql = SELECT "'", gr.id, IF(gr.id = @grId, "' selected>", "'>"), gr.value, ' (Id: ', gr.id, ')'
               FROM Ggroup AS gr
               INNER JOIN MailLog AS ml ON ml.grId = gr.id
               GROUP BY gr.id
      head = <form onchange='this.submit();' class='form-inline'><input type='hidden' name='id' value='{{pageAlias:T0}}'>
               Filter By Group: <select name='grId' class='form-control'><option value=''></option>
      rbeg = <option value=
      rend = </option>
      tail = </select>
    }

    20 {
      sql = SELECT IF(@summary = 'true', ' checked', '')
      head = <div class='checkbox'><label><input type='checkbox' name='summary' value='true'
      tail = >Summary</label></div></form>
    }

    # Mail Log
    50 {
      sql = SELECT id, '</td><td>', grId, '</td><td>', xId, '</td><td>'
                   , REPLACE(receiver, ',', '<br>'), '</td><td>', REPLACE(sender, ',', '<br>'), '</td><td>'
                   , DATE_FORMAT(modified, '%d.%m.%Y<br>%H:%i:%s'), '</td><td style="word-break:break-word;">'
                   , CONCAT('<b>', subject, '</b><br>', IF(@summary = 'true', CONCAT(SUBSTR(body, 1
                            , LEAST(IF(INSTR(body, '\n') = 0, 50, INSTR(body, '\n')), IF(INSTR(body, '<br>') = 0, 50
                            , INSTR(body, '<br>')))-1), ' ...'), CONCAT('<br>', REPLACE(body, '\n', '<br>'))) )
              FROM MailLog
              WHERE (grId = @grId OR @grId = 0)
              ORDER BY modified DESC
              LIMIT 100
      head = <table class="table table-condensed table-hover"><tr>
                 <th>Id</th><th>grId</th><th>xId</th><th>To</th><th>From</th><th>Date</th><th>E-Mail</th></tr>
      tail = </table>
      rbeg = <tr><td>
      rend = </td></tr>
    }

.. _REDIRECT_ALL_MAIL_TO:

Redirect all mail to (catch all)
--------------------------------

Setup in :ref:`configuration`

* *redirectAllMailTo=john@doe.com*

  * During the development, it might be helpful to configure a 'catch all' email address, which QFQ uses as the final receiver
    instead of the original intended one.

  * The setting will:

    * Replace the 'To' with the configured one.
    * Clear 'CC' and 'Bcc'
    * Write a note and the original configured receiver at the top of the email body.


Show log files realtime
-----------------------

Display QFQ log files in realtime.

The following QFQ code could be used for that purpose (put it in a QFQ PageContent element)::

   #
   # {{logfile:SU}}
   #

   # Show buttons to select log file.
   10 {
     sql = SELECT '{{logfile:SU:::sql.log}}' AS '_=logfile'
     head = <p>
     tail = </p>

     20.sql = SELECT CONCAT('p:{{pageAlias:T}}&logfile=sql.log|t:sql.log|b:', IF('{{logfile:R}}'='sql.log','primary','')) AS _page, ' '
                     , CONCAT('p:{{pageAlias:T}}&logfile=qfq.log|t:qfq.log|b:', IF('{{logfile:R}}'='qfq.log','primary','')) AS _page, ' '
                     , CONCAT('p:{{pageAlias:T}}&logfile=mail.log|t:mail.log|b:', IF('{{logfile:R}}'='mail.log','primary','')) AS _page
   }

   # Show selected log file.
   100 {
     sql = SELECT 'file:fileadmin/protected/log/{{logfile:R}}' AS _monitor
     head = <pre id="monitor-1">Please wait</pre>
   }


.. _`form-submit-log-page`:

Form Submit Log page
--------------------

For debugging purposes you may like to add a Form Submit Log page in the frontend.
The following QFQ code could be used for that purpose (put it in a QFQ PageContent element)::

    # Filters
    20.shead = <form onchange='this.submit()' class='form-inline'><input type='hidden' name='id' value='{{pageAlias:T0}}'>
    20 {
      sql = SELECT "'", id, IF(id = '{{formId:SC0}}', "' selected>", "'>"), name
              FROM Form
              ORDER BY name
      head = <label for='formId'>Form:</label> <select name='formId' id='formId' class='form-control'><option value=0></option>
      tail = </select>
      rbeg = <option value=
      rend = </option>
    }
    30 {
      sql = SELECT feUser, IF(feUser = '{{feUser:SCE:alnumx}}', "' selected>", "'>"), feUser
              FROM FormSubmitLog
              GROUP BY feUser ORDER BY feUser
      head = <label for='feUser'>FE User:</label> <select name='feUser' id='feUser' class='form-control'><option value=''></option>
      tail = </select>
      rbeg = <option value='
      rend = </option>
    }
    30.stail = </form>

    # Show Log
    50 {
      sql = SELECT l.id
                     , CONCAT('<b>Form</b>: ', f.name
                     , '<br><b>Record Id</b>: ', l.recordId
                     , '<br><b>Fe User</b>: ', l.feUser
                     , '<br><b>Date</b>: ', l.created
                     , '<br><b>Page Id</b>: ', l.pageId
                     , '<br><b>Session Id</b>: ', l.sessionId
                     , '<br><b>IP Address</b>: ', l.clientIp
                     , '<br><b>User Agent</b>: ', l.userAgent
                     , '<br><b>SIP Data</b>: <div style="margin-left:20px;">'
                     , "<script>var data = JSON.parse('", l.sipData, "'); for (var key in data) {
                                document.write('<b>' + key + '</b>: ' + data[key] + '<br>'); }</script>", '</div>')
                     , CONCAT("<script>var data = JSON.parse('", l.formData, "'); for (var key in data) {
                                document.write('<b>' + key + '</b>: ' + data[key] + '<br>'); }</script>")
                FROM FormSubmitLog AS l
                LEFT JOIN Form AS f
                  ON f.id = l.formId
                WHERE (l.formId = '{{formId:SC0}}' OR '{{formId:SC0}}' = 0)
                  AND (l.feUser = '{{feUser:SCE:alnumx}}' OR '{{feUser:SCE:alnumx}}' = '')
                ORDER BY l.created DESC
                LIMIT 100
      head = <table class="table table-hover">
             <tr><th>Id</th><th style="min-width:250px;">Environment</th><th>Submitted Data</th>
      tail = </table>
      rbeg = <tr>
      renr = </tr>
      fbeg = <td>
      fend = </td>
    }