Skip to content

Commit 524d239

Browse files
simahawkmmequignon
authored andcommitted
fixup! fixup! fixup! [REF] rest_log: Add hooks to read configuration from system params
1 parent 3e1665c commit 524d239

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

rest_log/components/service.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,12 @@ class BaseRESTService(AbstractComponent):
4040
_log_calls_in_db = False
4141

4242
def dispatch(self, method_name, *args, params=None):
43-
if self._server_debug_logging_active(method_name):
44-
_logger.debug(
45-
"REST call: %s.%s with args: %s and params: %s",
46-
self._collection._name,
47-
method_name,
48-
args,
49-
params,
50-
)
43+
call_name = f"{self._collection}.{self._usage}.{method_name}"
44+
_logger.debug("REST call: %s", call_name)
5145
if not self._db_logging_active(method_name):
5246
return super().dispatch(method_name, *args, params=params)
5347
if self._start_profiling(method_name):
54-
with Profiler(
55-
description=f"REST LOG {self._collection}.{self._usage}.{method_name}",
56-
):
48+
with Profiler(description=f"REST LOG {call_name}"):
5749
return self._dispatch_with_db_logging(method_name, *args, params=params)
5850
return self._dispatch_with_db_logging(method_name, *args, params=params)
5951

@@ -271,4 +263,10 @@ def _start_profiling(self, method_name):
271263
profiling_uid,
272264
f"{self._collection}.{self._usage}.{method_name}",
273265
)
266+
if not self.env["ir.profile"]._enabled_until():
267+
_logger.warning(
268+
"Profiling globally disabled for this DB. "
269+
"Set a future date in the system parameter '%(param_name)s'.",
270+
{"param_name": "base.profiling_enabled_until"},
271+
)
274272
return res

0 commit comments

Comments
 (0)