on master help sign in
Add independent log syntax
commit7c4edacb2be13eef3afe0e2b23fb83c7ca813dd7 authorKeith Hall <kingkeith+github@gmail.com> dateTue 6 Apr 2021, 23:50 (6 years ago) parent782ede5
4 files changed+125−55
assets/syntaxes/02_Extra/log.sublime-syntax+114 assets/syntaxes/02_Extra/syslog.sublime-syntax+7−55 tests/syntax-tests/highlighted/Log/example.log+2 tests/syntax-tests/source/Log/example.log+2
assets/syntaxes/02_Extra/log.sublime-syntaxnew file+114
@@ -0,0 +1,114 @@
1+%YAML 1.2
2+---
3+# See http://www.sublimetext.com/docs/3/syntax.html
4+file_extensions:
5+ - log
6+scope: text.log
7+variables:
8+ ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
9+contexts:
10+ main:
11+ - match: (\w+)(=)
12+ captures:
13+ 1: variable.parameter.log
14+ 2: keyword.operator.assignment.log
15+ - match: (')([^']*)(')
16+ scope: string.quoted.single.log
17+ captures:
18+ 1: punctuation.definition.string.begin.log
19+ 3: punctuation.definition.string.end.log
20+ - match: (")([^"]*)(")
21+ scope: string.quoted.double.log
22+ captures:
23+ 1: punctuation.definition.string.begin.log
24+ 3: punctuation.definition.string.end.log
25+ - include: dates
26+ - include: ip_addresses
27+ - include: numbers
28+ - match: \b(?i:fail(?:ure|ed)?|error)\b
29+ scope: invalid.illegal.error.log
30+ #- include: scope:text.html.markdown#autolink-inet
31+ - match: \b\w+:/{2,3}
32+ scope: markup.underline.link.scheme.log
33+ push: url-host
34+ dates:
35+ - match: \b\d{4}-\d{2}-\d{2}\b
36+ scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
37+ - match: \b\d{4}/\d{2}/\d{2}\b
38+ scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
39+ - match: \b(?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)(?:(\.)\d{3})?\b
40+ scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
41+ captures:
42+ 1: punctuation.separator.decimal.log
43+ ip_addresses:
44+ - match: (?=(?:{{ipv4_part}}\.){3}{{ipv4_part}})
45+ push:
46+ - meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log
47+ - match: \d+
48+ scope: constant.numeric.value.log
49+ - match: \.
50+ scope: punctuation.separator.sequence.log
51+ - match: ''
52+ pop: true
53+ - match: (?=(?:\h{0,4}:){2,6}\h{1,4})
54+ push:
55+ - meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
56+ - match: \h{1,4}
57+ scope: constant.numeric.value.log
58+ - match: ':'
59+ scope: punctuation.separator.sequence.log
60+ - match: ''
61+ pop: true
62+ numbers:
63+ - match: (0x)(\h+)(?:(\.)(\h+))?
64+ scope: meta.number.float.hexadecimal.log
65+ captures:
66+ 1: constant.numeric.base.log
67+ 2: constant.numeric.value.log
68+ 3: constant.numeric.value.log punctuation.separator.decimal.log
69+ 4: constant.numeric.value.log
70+ - match: \b\d+(\.)\d+\b
71+ scope: meta.number.float.log constant.numeric.value.log
72+ captures:
73+ 1: punctuation.separator.decimal.log
74+ - match: \b\d+\b
75+ scope: meta.number.integer.log constant.numeric.value.log
76+ url-host:
77+ - meta_content_scope: markup.underline.link.host.log
78+ - match: \[
79+ scope: punctuation.section.brackets.begin.log
80+ push:
81+ - match: \]
82+ scope: punctuation.section.brackets.end.log
83+ pop: true
84+ - include: ip_addresses
85+ - match: '[^:/\s]+'
86+ - match: ''
87+ set: url-after-host
88+ url-after-host:
89+ - match: (:)(\d+)
90+ scope: markup.underline.link.port.log
91+ captures:
92+ 1: punctuation.separator.mapping.port.log
93+ 2: constant.numeric.value.log
94+ #- include: scope:text.html.markdown#url-escaped-chars
95+ - match: (%)\h{2}
96+ scope: markup.underline.link.path.log constant.character.escape.url.log
97+ captures:
98+ 1: punctuation.definition.escape.log
99+ # After a valid domain, zero or more non-space non-< characters may follow
100+ - match: (?=[?!.,:*_~]*[\s<]) # Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link
101+ pop: true
102+ - match: \( # When an autolink ends in ), we scan the entire autolink for the total number of parentheses. If there is a greater number of closing parentheses than opening ones, we don’t consider the last character part of the autolink, in order to facilitate including an autolink inside a parenthesis
103+ push:
104+ - meta_scope: markup.underline.link.path.log
105+ - match: (?=[?!.,:*_~]*[\s<])
106+ pop: true
107+ - match: \)
108+ pop: true
109+ - match: (?=\)[?!.,:*_~]*[\s<])
110+ pop: true
111+ - match: '[^?!.,:*_~\s<&()%]+|\S'
112+ scope: markup.underline.link.path.log
113+ - match: ''
114+ pop: true
assets/syntaxes/02_Extra/syslog.sublime-syntax+7−55
@@ -5,8 +5,6 @@ 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]?)
108contexts:
119 main:
1210 - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
@@ -15,6 +13,8 @@ contexts:
1513 1: meta.date.syslog
1614 2: meta.time.syslog
1715 push: loghost
16+ - match: ^
17+ push: text
1818 loghost:
1919 - match: '[\w-]+'
2020 scope: entity.other.attribute-name.loghost.syslog
@@ -48,21 +48,10 @@ contexts:
4848 - match: (?=\S)
4949 set: text
5050 text:
51− - match: (\w+)(=)
52− captures:
53− 1: variable.parameter.syslog
54− 2: keyword.operator.assignment.syslog
55− - match: (')([^']*)(')
56− scope: string.quoted.single.syslog
57− captures:
58− 1: punctuation.definition.string.begin.syslog
59− 3: punctuation.definition.string.end.syslog
60− - match: (")([^"]*)(")
61− scope: string.quoted.double.syslog
62− captures:
63− 1: punctuation.definition.string.begin.syslog
64− 3: punctuation.definition.string.end.syslog
65− - include: numbers
51+ - match: $
52+ pop: true
53+ - match: '<\w+>'
54+ scope: constant.language.syslog
6655 - match: \b(CMD)\b\s+(\()
6756 captures:
6857 1: entity.name.label.syslog
@@ -71,41 +60,4 @@ contexts:
7160 escape: \)$
7261 escape_captures:
7362 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
78− - match: $
79− 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
63+ - include: scope:text.log
tests/syntax-tests/highlighted/Log/example.lognew file+2
@@ -0,0 +1,2 @@
1+2021-03-06 23:22:21.392 https://[2001:db8:4006:812::200e]:8080/path/the%20page.html
2+2021-03-06 23:22:21 https://example.com:8080/path/the%20page(with_parens).html
tests/syntax-tests/source/Log/example.lognew file+2
@@ -0,0 +1,2 @@
1+2021-03-06 23:22:21.392 https://[2001:db8:4006:812::200e]:8080/path/the%20page.html
2+2021-03-06 23:22:21 https://example.com:8080/path/the%20page(with_parens).html