blob: d58a1c4b9c7d8c421c8868b95880d6c528ffae1d [file] [log] [blame]
Éric Lemoine48f39bf2016-12-13 16:31:28 +01001# -*- coding: utf-8 -*-
2
3import os
4
5
6def syslog_file_match(output):
7 """
8 Return patterns to be used in logstreamer file_match config params.
9
10 For example the function may return this dict:
11
12 {
13 "/var/log": "kern\.log|auth\.log|syslog|mail\.log|mail\.err"
14 }
15 """
16 file_match = {}
17 for name, config in output.get('file', {}).items():
18 if not config.get('enabled', False):
19 continue
20 logdir = os.path.dirname(name)
21 pattern = os.path.basename(name).replace('.', '\.')
22 if logdir in file_match:
23 file_match[logdir] = file_match[logdir] + '|' + pattern
24 else:
25 file_match[logdir] = pattern
26 return file_match