Skip to content

Commit 39c2fb7

Browse files
committed
[IMP] rest_log: pre-commit auto fixes
1 parent 35bca34 commit 39c2fb7

15 files changed

+100
-96
lines changed

rest_log/README.rst

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ REST Log
1717
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818
:alt: License: LGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
20-
:target: https://github.com/OCA/rest-framework/tree/16.0/rest_log
20+
:target: https://github.com/OCA/rest-framework/tree/18.0/rest_log
2121
:alt: OCA/rest-framework
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/rest-framework-16-0/rest-framework-16-0-rest_log
23+
:target: https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-rest_log
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

3131
When exposing REST services is often useful to see what's happening
3232
especially in case of errors.
3333

34-
This module add DB logging for REST requests.
35-
It also inject in the response the URL of the log entry created.
34+
This module add DB logging for REST requests. It also inject in the
35+
response the URL of the log entry created.
3636

37-
NOTE: this feature was implemented initially inside shopfloor app.
38-
Up to version 13.0.1.2.1 of this module,
39-
if shopfloor is installed, log records will be copied from its table.
37+
NOTE: this feature was implemented initially inside shopfloor app. Up to
38+
version 13.0.1.2.1 of this module, if shopfloor is installed, log
39+
records will be copied from its table.
4040

4141
**Table of contents**
4242

@@ -47,44 +47,48 @@ Configuration
4747
=============
4848

4949
Logs retention
50-
~~~~~~~~~~~~~~
50+
--------------
5151

52-
Logs are kept in database for every REST requests made by a client application.
53-
They can be used for debugging and monitoring of the activity.
52+
Logs are kept in database for every REST requests made by a client
53+
application. They can be used for debugging and monitoring of the
54+
activity.
5455

55-
The Logs menu is shown only with Developer tools (``?debug=1``) activated.
56+
The Logs menu is shown only with Developer tools (``?debug=1``)
57+
activated.
5658

57-
By default, REST logs are kept 30 days.
58-
You can change the duration of the retention by changing the System Parameter
59+
By default, REST logs are kept 30 days. You can change the duration of
60+
the retention by changing the System Parameter
5961
``rest.log.retention.days``.
6062

6163
If the value is set to 0, the logs are not stored at all.
6264

63-
Logged data is: request URL and method, parameters, headers, result or error.
64-
65+
Logged data is: request URL and method, parameters, headers, result or
66+
error.
6567

6668
Logs activation
67-
~~~~~~~~~~~~~~~
69+
---------------
6870

6971
You have 2 ways to activate logging:
7072

71-
* on the service component set `_log_calls_in_db = True`
72-
* via configuration
73+
- on the service component set \_log_calls_in_db = True
74+
- via configuration
7375

7476
In the 1st case, calls will be always be logged.
7577

76-
In the 2nd case you can set ``rest.log.active`` param as::
78+
In the 2nd case you can set ``rest.log.active`` param as:
79+
80+
::
7781

78-
`collection_name` # enable for all endpoints of the collection
79-
`collection_name.usage` # enable for specific endpoints
80-
`collection_name.usage.endpoint` # enable for specific endpoints
81-
`collection_name*:state` # enable only for specific state (success, failed)
82+
`collection_name` # enable for all endpoints of the collection
83+
`collection_name.usage` # enable for specific endpoints
84+
`collection_name.usage.endpoint` # enable for specific endpoints
85+
`collection_name*:state` # enable only for specific state (success, failed)
8286

8387
Changelog
8488
=========
8589

8690
13.0.1.0.0
87-
~~~~~~~~~~
91+
----------
8892

8993
First official version.
9094

@@ -94,36 +98,36 @@ Bug Tracker
9498
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
9599
In case of trouble, please check there if your issue has already been reported.
96100
If you spotted it first, help us to smash it by providing a detailed and welcomed
97-
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20rest_log%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
101+
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20rest_log%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
98102

99103
Do not contact contributors directly about support or help with technical issues.
100104

101105
Credits
102106
=======
103107

104108
Authors
105-
~~~~~~~
109+
-------
106110

107111
* Camptocamp
108112
* ACSONE
109113

110114
Contributors
111-
~~~~~~~~~~~~
115+
------------
112116

113-
* Guewen Baconnier <[email protected]>
114-
* Simone Orsi <[email protected]>
117+
- Guewen Baconnier <[email protected]>
118+
- Simone Orsi <[email protected]>
115119

116120
Other credits
117-
~~~~~~~~~~~~~
121+
-------------
118122

119123
**Financial support**
120124

121-
* Cosanum
122-
* Camptocamp R&D
123-
* ACSONE R&D
125+
- Cosanum
126+
- Camptocamp R&D
127+
- ACSONE R&D
124128

125129
Maintainers
126-
~~~~~~~~~~~
130+
-----------
127131

128132
This module is maintained by the OCA.
129133

@@ -143,6 +147,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
143147

144148
|maintainer-simahawk|
145149

146-
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/16.0/rest_log>`_ project on GitHub.
150+
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18.0/rest_log>`_ project on GitHub.
147151

148152
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

rest_log/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class RESTServiceDispatchException(Exception):
8-
98
rest_json_info = {}
109

1110
def __init__(self, message, log_entry_url):

rest_log/models/rest_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _get_exception_severity_mapping(self):
8585
continue
8686
exc_name = severity = None
8787
try:
88-
exc_name, severity = [x.strip() for x in rule.split(":")]
88+
exc_name, severity = (x.strip() for x in rule.split(":"))
8989
if not exc_name or not severity:
9090
raise ValueError
9191
except ValueError:

rest_log/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

rest_log/readme/CONFIGURE.rst renamed to rest_log/readme/CONFIGURE.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
Logs retention
2-
~~~~~~~~~~~~~~
1+
## Logs retention
32

4-
Logs are kept in database for every REST requests made by a client application.
5-
They can be used for debugging and monitoring of the activity.
3+
Logs are kept in database for every REST requests made by a client
4+
application. They can be used for debugging and monitoring of the
5+
activity.
66

7-
The Logs menu is shown only with Developer tools (``?debug=1``) activated.
7+
The Logs menu is shown only with Developer tools (`?debug=1`) activated.
88

9-
By default, REST logs are kept 30 days.
10-
You can change the duration of the retention by changing the System Parameter
11-
``rest.log.retention.days``.
9+
By default, REST logs are kept 30 days. You can change the duration of
10+
the retention by changing the System Parameter
11+
`rest.log.retention.days`.
1212

1313
If the value is set to 0, the logs are not stored at all.
1414

15-
Logged data is: request URL and method, parameters, headers, result or error.
15+
Logged data is: request URL and method, parameters, headers, result or
16+
error.
1617

17-
18-
Logs activation
19-
~~~~~~~~~~~~~~~
18+
## Logs activation
2019

2120
You have 2 ways to activate logging:
2221

23-
* on the service component set `_log_calls_in_db = True`
24-
* via configuration
22+
- on the service component set \_log_calls_in_db = True
23+
- via configuration
2524

2625
In the 1st case, calls will be always be logged.
2726

28-
In the 2nd case you can set ``rest.log.active`` param as::
27+
In the 2nd case you can set `rest.log.active` param as:
2928

3029
`collection_name` # enable for all endpoints of the collection
3130
`collection_name.usage` # enable for specific endpoints

rest_log/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Guewen Baconnier \<[email protected]\>
2+
- Simone Orsi \<[email protected]\>

rest_log/readme/CONTRIBUTORS.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

rest_log/readme/CREDITS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**Financial support**
2+
3+
- Cosanum
4+
- Camptocamp R&D
5+
- ACSONE R&D

rest_log/readme/CREDITS.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

rest_log/readme/DESCRIPTION.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
When exposing REST services is often useful to see what's happening
2+
especially in case of errors.
3+
4+
This module add DB logging for REST requests. It also inject in the
5+
response the URL of the log entry created.
6+
7+
NOTE: this feature was implemented initially inside shopfloor app. Up to
8+
version 13.0.1.2.1 of this module, if shopfloor is installed, log
9+
records will be copied from its table.

rest_log/readme/DESCRIPTION.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
13.0.1.0.0
2-
~~~~~~~~~~
1+
## 13.0.1.0.0
32

43
First official version.

rest_log/static/description/index.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
/*
1010
:Author: David Goodger ([email protected])
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
1716
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -369,14 +368,14 @@ <h1 class="title">REST Log</h1>
369368
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370369
!! source digest: sha256:f93e58dbd77af1254adb0cd7ace54af0b0609569883ed4a22028f11f0b663139
371370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/16.0/rest_log"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-16-0/rest-framework-16-0-rest_log"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/18.0/rest_log"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-rest_log"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373372
<p>When exposing REST services is often useful to see what’s happening
374373
especially in case of errors.</p>
375-
<p>This module add DB logging for REST requests.
376-
It also inject in the response the URL of the log entry created.</p>
377-
<p>NOTE: this feature was implemented initially inside shopfloor app.
378-
Up to version 13.0.1.2.1 of this module,
379-
if shopfloor is installed, log records will be copied from its table.</p>
374+
<p>This module add DB logging for REST requests. It also inject in the
375+
response the URL of the log entry created.</p>
376+
<p>NOTE: this feature was implemented initially inside shopfloor app. Up to
377+
version 13.0.1.2.1 of this module, if shopfloor is installed, log
378+
records will be copied from its table.</p>
380379
<p><strong>Table of contents</strong></p>
381380
<div class="contents local topic" id="contents">
382381
<ul class="simple">
@@ -403,20 +402,23 @@ <h1 class="title">REST Log</h1>
403402
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
404403
<div class="section" id="logs-retention">
405404
<h2><a class="toc-backref" href="#toc-entry-2">Logs retention</a></h2>
406-
<p>Logs are kept in database for every REST requests made by a client application.
407-
They can be used for debugging and monitoring of the activity.</p>
408-
<p>The Logs menu is shown only with Developer tools (<tt class="docutils literal"><span class="pre">?debug=1</span></tt>) activated.</p>
409-
<p>By default, REST logs are kept 30 days.
410-
You can change the duration of the retention by changing the System Parameter
405+
<p>Logs are kept in database for every REST requests made by a client
406+
application. They can be used for debugging and monitoring of the
407+
activity.</p>
408+
<p>The Logs menu is shown only with Developer tools (<tt class="docutils literal"><span class="pre">?debug=1</span></tt>)
409+
activated.</p>
410+
<p>By default, REST logs are kept 30 days. You can change the duration of
411+
the retention by changing the System Parameter
411412
<tt class="docutils literal">rest.log.retention.days</tt>.</p>
412413
<p>If the value is set to 0, the logs are not stored at all.</p>
413-
<p>Logged data is: request URL and method, parameters, headers, result or error.</p>
414+
<p>Logged data is: request URL and method, parameters, headers, result or
415+
error.</p>
414416
</div>
415417
<div class="section" id="logs-activation">
416418
<h2><a class="toc-backref" href="#toc-entry-3">Logs activation</a></h2>
417419
<p>You have 2 ways to activate logging:</p>
418420
<ul class="simple">
419-
<li>on the service component set <cite>_log_calls_in_db = True</cite></li>
421+
<li>on the service component set _log_calls_in_db = True</li>
420422
<li>via configuration</li>
421423
</ul>
422424
<p>In the 1st case, calls will be always be logged.</p>
@@ -441,7 +443,7 @@ <h1><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h1>
441443
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rest-framework/issues">GitHub Issues</a>.
442444
In case of trouble, please check there if your issue has already been reported.
443445
If you spotted it first, help us to smash it by providing a detailed and welcomed
444-
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20rest_log%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
446+
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20rest_log%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
445447
<p>Do not contact contributors directly about support or help with technical issues.</p>
446448
</div>
447449
<div class="section" id="credits">
@@ -472,15 +474,13 @@ <h2><a class="toc-backref" href="#toc-entry-10">Other credits</a></h2>
472474
<div class="section" id="maintainers">
473475
<h2><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h2>
474476
<p>This module is maintained by the OCA.</p>
475-
<a class="reference external image-reference" href="https://odoo-community.org">
476-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
477-
</a>
477+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
478478
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
479479
mission is to support the collaborative development of Odoo features and
480480
promote its widespread use.</p>
481481
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
482482
<p><a class="reference external image-reference" href="https://github.com/simahawk"><img alt="simahawk" src="https://github.com/simahawk.png?size=40px" /></a></p>
483-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/16.0/rest_log">OCA/rest-framework</a> project on GitHub.</p>
483+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/18.0/rest_log">OCA/rest-framework</a> project on GitHub.</p>
484484
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
485485
</div>
486486
</div>

rest_log/tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from odoo.addons.website.tools import MockRequest
1212

1313

14-
class TestDBLoggingMixin(object):
14+
class TestDBLoggingMixin:
1515
@staticmethod
1616
def _get_service(class_or_instance, collection=None):
1717
# pylint: disable=R7980

rest_log/tests/test_db_logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def test_log_enabled_conf_parsing(self):
4040
expected = {
4141
# fmt:off
4242
"coll1.service1.endpoint": ("success", "failed"),
43-
"coll1.service2.endpoint": ("failed", ),
44-
"coll2.service1.endpoint": ("success", ),
43+
"coll1.service2.endpoint": ("failed",),
44+
"coll2.service1.endpoint": ("success",),
4545
# fmt: on
4646
}
4747
self.assertEqual(self.env["rest.log"]._get_log_active_conf(), expected)

0 commit comments

Comments
 (0)