@@ -44,7 +44,10 @@ def dispatch(self, method_name, *args, params=None):
4444 return super ().dispatch (method_name , * args , params = params )
4545 if self ._start_profiling (method_name ):
4646 call_name = f"{ self ._collection } .{ self ._usage } .{ method_name } "
47- with Profiler (description = f"REST LOG { call_name } " ):
47+ with Profiler (
48+ description = f"REST LOG { call_name } "
49+ f"by { self .env .user .name } (uid={ self .env .uid } )"
50+ ):
4851 return self ._dispatch_with_db_logging (method_name , * args , params = params )
4952 return self ._dispatch_with_db_logging (method_name , * args , params = params )
5053
@@ -233,30 +236,35 @@ def _get_matching_active_conf(self, method_name):
233236 def _start_profiling (self , method_name ):
234237 if request .session .profile_session and request .db :
235238 return None
236- profiling_uids = 0
239+ profiling_uids = self ._profiling_get_uids ()
240+ profiling_conf_match = self ._profiling_get_matching_conf (method_name )
241+ res = profiling_conf_match and self .env .uid in profiling_uids
242+ if res :
243+ _logger .info (
244+ "Profiling enabled for uids=%s %s" ,
245+ str (profiling_uids ),
246+ f"{ self ._collection } .{ self ._usage } .{ method_name } " ,
247+ )
248+ return res
249+
250+ def _profiling_get_uids (self ):
237251 try :
238- profiling_uids = [
239- int (x )
240- for x in self .env ["ir.config_parameter" ]
252+ param = (
253+ self .env ["ir.config_parameter" ]
241254 .sudo ()
242255 .get_param ("rest.log.profiling.uid" , "" )
243- .split ("," )
244- ]
256+ )
257+ if not param .strip ():
258+ return []
259+ return [int (x .strip ()) for x in param .strip ().split ("," ) if x .strip ()]
245260 except ValueError as err :
246261 _logger .warning (
247262 "Cannot get uid from system parameter rest.log.profiling.uid: %s" ,
248263 str (err ),
249264 )
250- res = (
251- self . env [ "rest.log" ]. _get_matching_conf_from_param (
252- "rest.log.profiling.conf" , self . _collection , self . _usage , method_name
253- )
254- and self .env . uid in profiling_uids
265+ return []
266+
267+ def _profiling_get_matching_conf ( self , method_name ):
268+ return self . env [ "rest.log" ]. _get_matching_conf_from_param (
269+ "rest.log.profiling.conf" , self ._collection , self . _usage , method_name
255270 )
256- if res :
257- _logger .info (
258- "Profiling enabled for uids=%s %s" ,
259- str (profiling_uids ),
260- f"{ self ._collection } .{ self ._usage } .{ method_name } " ,
261- )
262- return res
0 commit comments