on master help sign in
improve syslog syntax
commit782ede5db5ad601e44468c9ca32bd201e5c75aaa authorKeith Hall <kingkeith+github@gmail.com> dateMon 5 Apr 2021, 22:17 (6 years ago) parent1537733
3 files changed+63−10
assets/syntaxes/02_Extra/syslog.sublime-syntax+46−5 tests/syntax-tests/highlighted/Syslog/example.syslog+11−5 tests/syntax-tests/source/Syslog/example.syslog+6
assets/syntaxes/02_Extra/syslog.sublime-syntax+46−5
@@ -5,10 +5,15 @@ name: syslog
55file_extensions:
66 - syslog
77scope: text.syslog
8+variables:
9+ ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
810contexts:
911 main:
10− - match: '^\w+\s+\d+\s+\d{2}:\d{2}:\d{2}'
12+ - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
1113 scope: meta.datetime.syslog constant.numeric.syslog
14+ captures:
15+ 1: meta.date.syslog
16+ 2: meta.time.syslog
1217 push: loghost
1318 loghost:
1419 - match: '[\w-]+'
@@ -20,7 +25,8 @@ contexts:
2025 1: support.function.process.syslog
2126 2: punctuation.separator.pid.begin.syslog
2227 3: meta.pid.syslog meta.number.integer.syslog constant.numeric.value.syslog
23− 4: punctuation.separator.mapping.syslog
28+ 4: punctuation.separator.pid.end.syslog
29+ 5: punctuation.separator.mapping.syslog
2430 set: structured-data
2531 structured-data:
2632 - match: '\['
@@ -56,15 +62,50 @@ contexts:
5662 captures:
5763 1: punctuation.definition.string.begin.syslog
5864 3: punctuation.definition.string.end.syslog
59− - match: \d+
60− scope: meta.number.integer.syslog constant.numeric.value.syslog
65+ - include: numbers
6166 - match: \b(CMD)\b\s+(\()
6267 captures:
6368 1: entity.name.label.syslog
6469 2: punctuation.section.block.begin.syslog
6570 embed: scope:source.shell.bash
66− escape: \)
71+ escape: \)$
6772 escape_captures:
6873 0: punctuation.section.block.end.syslog
74+ - match: '<\w+>'
75+ scope: constant.language.syslog
76+ - match: (?i:fail(?:ure|ed)?|error)
77+ scope: invalid.illegal.error.syslog
6978 - match: $
7079 pop: true
80+ numbers:
81+ - match: (?=(?:{{ipv4_part}}\.){3}{{ipv4_part}})
82+ push:
83+ - meta_scope: meta.ipaddress.v4.syslog meta.number.integer.decimal.syslog
84+ - match: \d+
85+ scope: constant.numeric.value.syslog
86+ - match: \.
87+ scope: punctuation.separator.sequence.syslog
88+ - match: ''
89+ pop: true
90+ - match: (?=(?:\h{0,4}:){2,6}\h{1,4})
91+ push:
92+ - meta_scope: meta.ipaddress.v6.syslog meta.number.integer.hexadecimal.syslog
93+ - match: \h{1,4}
94+ scope: constant.numeric.value.syslog
95+ - match: ':'
96+ scope: punctuation.separator.sequence.syslog
97+ - match: ''
98+ pop: true
99+ - match: (0x)(\h+)(?:(\.)(\h+))?
100+ scope: meta.number.float.hexadecimal.syslog
101+ captures:
102+ 1: constant.numeric.base.syslog
103+ 2: constant.numeric.value.syslog
104+ 3: constant.numeric.value.syslog punctuation.separator.decimal.syslog
105+ 4: constant.numeric.value.syslog
106+ - match: \b\d+(\.)\d+\b
107+ scope: meta.number.float.syslog constant.numeric.value.syslog
108+ captures:
109+ 1: punctuation.separator.decimal.syslog
110+ - match: \b\d+\b
111+ scope: meta.number.integer.syslog constant.numeric.value.syslog
tests/syntax-tests/highlighted/Syslog/example.syslog+11−5
@@ -1,5 +1,11 @@
1−Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded.
2−Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files.
3−Apr 4 00:00:21 hostname-here kernel: [55604.908232] audit: type=1400 audit(1617483621.094:28): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=59311 comm="cups-browsed" capability=23 capname="sys_nice"
4−Apr 4 09:30:01 hostname-here CRON[89278]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
5−Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid'
1+Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded.
2+Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files.
3+Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available
4+Apr 4 00:00:21 hostname-here kernel: [55604.908232] audit: type=1400 audit(1617483621.094:28): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=59311 comm="cups-browsed" capability=23 capname="sys_nice"
5+Apr 4 00:01:38 hostname-here systemd-resolved[721]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
6+Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37
7+Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 -> <null>
8+Apr 4 00:06:29 hostname-here ntpd[952]: receive: Unexpected origin timestamp 0xe414a8d1.82e825f5 does not match aorg 0xe414a8d5.82c50d8c from server@127.0.0.1 xmt 0xe414a8d1.e671d7c4
9+Apr 4 09:30:01 hostname-here CRON[89278]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
10+Apr 4 16:32:07 hostname-here NetworkManager[740]: <info> [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL
11+Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid'
tests/syntax-tests/source/Syslog/example.syslog+6
@@ -1,5 +1,11 @@
11Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded.
22Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files.
3+Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available
34Apr 4 00:00:21 hostname-here kernel: [55604.908232] audit: type=1400 audit(1617483621.094:28): apparmor="DENIED" operation="capable" profile="/usr/sbin/cups-browsed" pid=59311 comm="cups-browsed" capability=23 capname="sys_nice"
5+Apr 4 00:01:38 hostname-here systemd-resolved[721]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
6+Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37
7+Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 -> <null>
8+Apr 4 00:06:29 hostname-here ntpd[952]: receive: Unexpected origin timestamp 0xe414a8d1.82e825f5 does not match aorg 0xe414a8d5.82c50d8c from server@127.0.0.1 xmt 0xe414a8d1.e671d7c4
49Apr 4 09:30:01 hostname-here CRON[89278]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
10+Apr 4 16:32:07 hostname-here NetworkManager[740]: <info> [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL
511Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid'