From 74164d89c930a5cb2b3dc686031aa1e2c5615ab6 Mon Sep 17 00:00:00 2001
From: Alex Fikl <alexfikl@gmail.com>
Date: Mon, 11 Oct 2021 16:13:16 -0500
Subject: [PATCH] Allow passing threshold to log_process decorator (#103)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* allow passing threshold to log_process decorator

* Add method docs for log_process

Co-authored-by: Andreas Klöckner <inform@tiker.net>
---
 pytools/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/pytools/__init__.py b/pytools/__init__.py
index 4ee4fc1..4d98418 100644
--- a/pytools/__init__.py
+++ b/pytools/__init__.py
@@ -2524,17 +2524,22 @@ class DebugProcessLogger(ProcessLogger):
 class log_process:  # noqa: N801
     """A decorator that uses :class:`ProcessLogger` to log data about calls
     to the wrapped function.
+
+    .. automethod:: __init__
+    .. automethod:: __call__
     """
 
-    def __init__(self, logger, description=None):
+    def __init__(self, logger, description=None, long_threshold_seconds=None):
         self.logger = logger
         self.description = description
+        self.long_threshold_seconds = long_threshold_seconds
 
     def __call__(self, wrapped):
         def wrapper(*args, **kwargs):
             with ProcessLogger(
                     self.logger,
-                    self.description or wrapped.__name__):
+                    self.description or wrapped.__name__,
+                    long_threshold_seconds=self.long_threshold_seconds):
                 return wrapped(*args, **kwargs)
 
         from functools import update_wrapper
-- 
GitLab