diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-03-18 03:20:18 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-03-22 14:08:01 +0100 |
commit | aefcc576a5b0114a2c9fafcdbd37c28e2ffd9e62 (patch) | |
tree | e38200bb462970fa46b375b3a840fefcf0da6d44 /recording | |
parent | ad088a1a29f6871952ced88032cc94ac3e9a56b8 (diff) |
Generalize helper to log the output of a process
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'recording')
-rw-r--r-- | recording/src/nextcloud/talk/recording/Service.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/recording/src/nextcloud/talk/recording/Service.py b/recording/src/nextcloud/talk/recording/Service.py index ad436d10b..cb11a51b9 100644 --- a/recording/src/nextcloud/talk/recording/Service.py +++ b/recording/src/nextcloud/talk/recording/Service.py @@ -124,12 +124,13 @@ def newAudioSink(baseSinkName): return moduleIndex, sinkIndex -def recorderLog(loggerName, pipe): +def processLog(loggerName, pipe, level = logging.INFO): """ - Logs the recorder output. + Logs the process output. :param loggerName: the name of the logger. - :param pipe: Pipe to the recorder process output. + :param pipe: Pipe to the process output. + :param level: log level, INFO by default. """ logger = logging.getLogger(loggerName) @@ -137,7 +138,7 @@ def recorderLog(loggerName, pipe): for line in pipe: # Lines captured from the recorder have a trailing new line, so it # needs to be removed. - logger.info(line.rstrip('\n')) + logger.log(level, line.rstrip('\n')) class Service: """ @@ -253,7 +254,7 @@ class Service: self._process = subprocess.Popen(recorderArgs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) # Log recorder output. - Thread(target=recorderLog, args=[f"{__name__}.recorder-{self.backend}-{self.token}", self._process.stdout], daemon=True).start() + Thread(target=processLog, args=[f"{__name__}.recorder-{self.backend}-{self.token}", self._process.stdout], daemon=True).start() if self._stopped.is_set(): # Not strictly needed, as if the recorder is started after the |