mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-15 07:10:43 +01:00
Add independent log syntax
This commit is contained in:
parent
782ede5db5
commit
7c4edacb2b
114
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
Normal file
114
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# See http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
file_extensions:
|
||||||
|
- log
|
||||||
|
scope: text.log
|
||||||
|
variables:
|
||||||
|
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: (\w+)(=)
|
||||||
|
captures:
|
||||||
|
1: variable.parameter.log
|
||||||
|
2: keyword.operator.assignment.log
|
||||||
|
- match: (')([^']*)(')
|
||||||
|
scope: string.quoted.single.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
3: punctuation.definition.string.end.log
|
||||||
|
- match: (")([^"]*)(")
|
||||||
|
scope: string.quoted.double.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
3: punctuation.definition.string.end.log
|
||||||
|
- include: dates
|
||||||
|
- include: ip_addresses
|
||||||
|
- include: numbers
|
||||||
|
- match: \b(?i:fail(?:ure|ed)?|error)\b
|
||||||
|
scope: invalid.illegal.error.log
|
||||||
|
#- include: scope:text.html.markdown#autolink-inet
|
||||||
|
- match: \b\w+:/{2,3}
|
||||||
|
scope: markup.underline.link.scheme.log
|
||||||
|
push: url-host
|
||||||
|
dates:
|
||||||
|
- match: \b\d{4}-\d{2}-\d{2}\b
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
- match: \b\d{4}/\d{2}/\d{2}\b
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
- match: \b(?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)(?:(\.)\d{3})?\b
|
||||||
|
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
ip_addresses:
|
||||||
|
- match: (?=(?:{{ipv4_part}}\.){3}{{ipv4_part}})
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log
|
||||||
|
- match: \d+
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: \.
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
- match: (?=(?:\h{0,4}:){2,6}\h{1,4})
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
|
||||||
|
- match: \h{1,4}
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
numbers:
|
||||||
|
- match: (0x)(\h+)(?:(\.)(\h+))?
|
||||||
|
scope: meta.number.float.hexadecimal.log
|
||||||
|
captures:
|
||||||
|
1: constant.numeric.base.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
3: constant.numeric.value.log punctuation.separator.decimal.log
|
||||||
|
4: constant.numeric.value.log
|
||||||
|
- match: \b\d+(\.)\d+\b
|
||||||
|
scope: meta.number.float.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
- match: \b\d+\b
|
||||||
|
scope: meta.number.integer.log constant.numeric.value.log
|
||||||
|
url-host:
|
||||||
|
- meta_content_scope: markup.underline.link.host.log
|
||||||
|
- match: \[
|
||||||
|
scope: punctuation.section.brackets.begin.log
|
||||||
|
push:
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.brackets.end.log
|
||||||
|
pop: true
|
||||||
|
- include: ip_addresses
|
||||||
|
- match: '[^:/\s]+'
|
||||||
|
- match: ''
|
||||||
|
set: url-after-host
|
||||||
|
url-after-host:
|
||||||
|
- match: (:)(\d+)
|
||||||
|
scope: markup.underline.link.port.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.mapping.port.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
#- include: scope:text.html.markdown#url-escaped-chars
|
||||||
|
- match: (%)\h{2}
|
||||||
|
scope: markup.underline.link.path.log constant.character.escape.url.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.escape.log
|
||||||
|
# After a valid domain, zero or more non-space non-< characters may follow
|
||||||
|
- 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
|
||||||
|
pop: true
|
||||||
|
- 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
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.underline.link.path.log
|
||||||
|
- match: (?=[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: \)
|
||||||
|
pop: true
|
||||||
|
- match: (?=\)[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: '[^?!.,:*_~\s<&()%]+|\S'
|
||||||
|
scope: markup.underline.link.path.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
62
assets/syntaxes/02_Extra/syslog.sublime-syntax
vendored
62
assets/syntaxes/02_Extra/syslog.sublime-syntax
vendored
@ -5,8 +5,6 @@ name: syslog
|
|||||||
file_extensions:
|
file_extensions:
|
||||||
- syslog
|
- syslog
|
||||||
scope: text.syslog
|
scope: text.syslog
|
||||||
variables:
|
|
||||||
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
|
||||||
contexts:
|
contexts:
|
||||||
main:
|
main:
|
||||||
- match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
|
- match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
|
||||||
@ -15,6 +13,8 @@ contexts:
|
|||||||
1: meta.date.syslog
|
1: meta.date.syslog
|
||||||
2: meta.time.syslog
|
2: meta.time.syslog
|
||||||
push: loghost
|
push: loghost
|
||||||
|
- match: ^
|
||||||
|
push: text
|
||||||
loghost:
|
loghost:
|
||||||
- match: '[\w-]+'
|
- match: '[\w-]+'
|
||||||
scope: entity.other.attribute-name.loghost.syslog
|
scope: entity.other.attribute-name.loghost.syslog
|
||||||
@ -48,21 +48,10 @@ contexts:
|
|||||||
- match: (?=\S)
|
- match: (?=\S)
|
||||||
set: text
|
set: text
|
||||||
text:
|
text:
|
||||||
- match: (\w+)(=)
|
- match: $
|
||||||
captures:
|
pop: true
|
||||||
1: variable.parameter.syslog
|
- match: '<\w+>'
|
||||||
2: keyword.operator.assignment.syslog
|
scope: constant.language.syslog
|
||||||
- match: (')([^']*)(')
|
|
||||||
scope: string.quoted.single.syslog
|
|
||||||
captures:
|
|
||||||
1: punctuation.definition.string.begin.syslog
|
|
||||||
3: punctuation.definition.string.end.syslog
|
|
||||||
- match: (")([^"]*)(")
|
|
||||||
scope: string.quoted.double.syslog
|
|
||||||
captures:
|
|
||||||
1: punctuation.definition.string.begin.syslog
|
|
||||||
3: punctuation.definition.string.end.syslog
|
|
||||||
- include: numbers
|
|
||||||
- match: \b(CMD)\b\s+(\()
|
- match: \b(CMD)\b\s+(\()
|
||||||
captures:
|
captures:
|
||||||
1: entity.name.label.syslog
|
1: entity.name.label.syslog
|
||||||
@ -71,41 +60,4 @@ contexts:
|
|||||||
escape: \)$
|
escape: \)$
|
||||||
escape_captures:
|
escape_captures:
|
||||||
0: punctuation.section.block.end.syslog
|
0: punctuation.section.block.end.syslog
|
||||||
- match: '<\w+>'
|
- include: scope:text.log
|
||||||
scope: constant.language.syslog
|
|
||||||
- match: (?i:fail(?:ure|ed)?|error)
|
|
||||||
scope: invalid.illegal.error.syslog
|
|
||||||
- match: $
|
|
||||||
pop: true
|
|
||||||
numbers:
|
|
||||||
- match: (?=(?:{{ipv4_part}}\.){3}{{ipv4_part}})
|
|
||||||
push:
|
|
||||||
- meta_scope: meta.ipaddress.v4.syslog meta.number.integer.decimal.syslog
|
|
||||||
- match: \d+
|
|
||||||
scope: constant.numeric.value.syslog
|
|
||||||
- match: \.
|
|
||||||
scope: punctuation.separator.sequence.syslog
|
|
||||||
- match: ''
|
|
||||||
pop: true
|
|
||||||
- match: (?=(?:\h{0,4}:){2,6}\h{1,4})
|
|
||||||
push:
|
|
||||||
- meta_scope: meta.ipaddress.v6.syslog meta.number.integer.hexadecimal.syslog
|
|
||||||
- match: \h{1,4}
|
|
||||||
scope: constant.numeric.value.syslog
|
|
||||||
- match: ':'
|
|
||||||
scope: punctuation.separator.sequence.syslog
|
|
||||||
- match: ''
|
|
||||||
pop: true
|
|
||||||
- match: (0x)(\h+)(?:(\.)(\h+))?
|
|
||||||
scope: meta.number.float.hexadecimal.syslog
|
|
||||||
captures:
|
|
||||||
1: constant.numeric.base.syslog
|
|
||||||
2: constant.numeric.value.syslog
|
|
||||||
3: constant.numeric.value.syslog punctuation.separator.decimal.syslog
|
|
||||||
4: constant.numeric.value.syslog
|
|
||||||
- match: \b\d+(\.)\d+\b
|
|
||||||
scope: meta.number.float.syslog constant.numeric.value.syslog
|
|
||||||
captures:
|
|
||||||
1: punctuation.separator.decimal.syslog
|
|
||||||
- match: \b\d+\b
|
|
||||||
scope: meta.number.integer.syslog constant.numeric.value.syslog
|
|
||||||
|
2
tests/syntax-tests/highlighted/Log/example.log
Normal file
2
tests/syntax-tests/highlighted/Log/example.log
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[38;2;190;132;255m2021-03-06[0m[38;2;248;248;242m [0m[38;2;190;132;255m23:22:21[0m[38;2;190;132;255m.[0m[38;2;190;132;255m392[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://[0m[4;38;2;166;226;46m[[0m[4;38;2;190;132;255m2001[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255mdb8[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m4006[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m812[0m[4;38;2;166;226;46m:[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m200e[0m[4;38;2;166;226;46m][0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m8080[0m[4;38;2;166;226;46m/path/the[0m[4;38;2;190;132;255m%[0m[4;38;2;190;132;255m20[0m[4;38;2;166;226;46mpage[0m[4;38;2;166;226;46m.[0m[4;38;2;166;226;46mhtml[0m
|
||||||
|
[38;2;190;132;255m2021-03-06[0m[38;2;248;248;242m [0m[38;2;190;132;255m23:22:21[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhttps://[0m[4;38;2;166;226;46mexample.com[0m[4;38;2;166;226;46m:[0m[4;38;2;190;132;255m8080[0m[4;38;2;166;226;46m/path/the[0m[4;38;2;190;132;255m%[0m[4;38;2;190;132;255m20[0m[4;38;2;166;226;46mpage[0m[4;38;2;166;226;46m(with_parens)[0m[4;38;2;166;226;46m.[0m[4;38;2;166;226;46mhtml[0m
|
2
tests/syntax-tests/source/Log/example.log
Normal file
2
tests/syntax-tests/source/Log/example.log
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
2021-03-06 23:22:21.392 https://[2001:db8:4006:812::200e]:8080/path/the%20page.html
|
||||||
|
2021-03-06 23:22:21 https://example.com:8080/path/the%20page(with_parens).html
|
Loading…
x
Reference in New Issue
Block a user