From f00a9b9ad5d7236c354de0e7b6a60f9a70c70d88 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 21 Feb 2019 12:59:46 +0000 Subject: [Plugin] accept predicates in Plugin.add_copy_spec() Signed-off-by: Bryn M. Reeves --- sos/plugins/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index 2f6ca040..cf8583ce 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -695,11 +695,16 @@ class Plugin(object): def _add_copy_paths(self, copy_paths): self.copy_paths.update(copy_paths) - def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True): + def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True, pred=None): """Add a file or glob but limit it to sizelimit megabytes. If fname is a single file the file will be tailed to meet sizelimit. If the first file in a glob is too large it will be tailed to meet the sizelimit. """ + if pred is not None and not pred: + self._log_info("skipped copy spec '%s' due to predicate (%s)" % + (copyspecs, pred)) + return + if sizelimit is None: sizelimit = self.get_option("log_size") -- cgit