-
Notifications
You must be signed in to change notification settings - Fork 0
/
fmt.py
34 lines (22 loc) · 838 Bytes
/
fmt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import sys
import jctlfmt
from jctlfmt import Prio
class Formatter(jctlfmt.BaseFormatter):
def fmt(self, x: jctlfmt.Entry) -> str:
if x.str_uip == 'kernel':
if x.prio >= Prio.INFO:
return self.fmt_none(x)
elif x.prio == Prio.NOTICE and not x.msg.startswith('Linux version '):
return self.fmt_none(x)
if x.str_pm.startswith('<5>Linux version '):
return self.fmt_nopid_msg(x, 'Linux version ...')
elif x.str_ui == '(myapp.service) myapp':
if x.prio >= Prio.INFO:
return self.fmt_none(x)
return self.fmt_nopid(x)
return self.fmt_nopid_nomsg(x)
def main(argv=None):
return jctlfmt.exec(Formatter, argv)
if __name__ == '__main__':
sys.exit(main())