Skip to content

Commit

Permalink
refactor: use regex to filter nbdkit logs
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
  • Loading branch information
Millefeuille42 committed Mar 3, 2025
1 parent 5191100 commit d8244e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nbd_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,17 @@ def clean_paths():

# Continue to log server messages in stdout.
def log_server_messages():
nbdkit_log_prefix = r'nbdkit: multihttp\[\d+\]: debug: '
verbose_keywords = (
'pread',
'pwrite'
)
verbose_pattern = re.compile(r'{}({})'.format(nbdkit_log_prefix, '|'.join(verbose_keywords)))

while server.poll() is None:
line = server.stdout.readline().rstrip('\n')
if line:
if any(keyword in line for keyword in verbose_keywords):
if any(verbose_pattern.match(line) for keyword in verbose_keywords):
dprint(line)
else:
thread_print(line)
Expand Down

0 comments on commit d8244e8

Please sign in to comment.