mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-21 23:33:26 +01:00
Syntax: [Log] scope whole line based on log level
to allow color schemes to color entire lines differently based on log level
This commit is contained in:
parent
45d6b1af3b
commit
c6775cc41e
76
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
76
assets/syntaxes/02_Extra/log.sublime-syntax
vendored
@ -7,8 +7,15 @@ scope: text.log
|
|||||||
variables:
|
variables:
|
||||||
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
||||||
hours_minutes_seconds: (?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)
|
hours_minutes_seconds: (?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)
|
||||||
|
error: \b(?i:fail(?:ure|ed)?|error|exception|fatal|critical)\b
|
||||||
|
warning: \b(?i:warn(?:ing)?)\b
|
||||||
|
info: \b(?i:info)\b
|
||||||
|
debug: \b(?i:debug)\b
|
||||||
contexts:
|
contexts:
|
||||||
main:
|
main:
|
||||||
|
- include: log_level_lines
|
||||||
|
- include: main_without_log_level_line
|
||||||
|
main_without_log_level_line:
|
||||||
- match: (\w+)(=)
|
- match: (\w+)(=)
|
||||||
captures:
|
captures:
|
||||||
1: variable.parameter.log
|
1: variable.parameter.log
|
||||||
@ -25,16 +32,58 @@ contexts:
|
|||||||
- include: dates
|
- include: dates
|
||||||
- include: ip_addresses
|
- include: ip_addresses
|
||||||
- include: numbers
|
- include: numbers
|
||||||
- match: \b(?i:fail(?:ure|ed)?|error|exception)\b
|
- include: log_levels
|
||||||
scope: markup.error.log
|
|
||||||
- match: \b(?i:warn(?:ing)?)\b
|
|
||||||
scope: markup.warning.log
|
|
||||||
- match: \b(?i:debug)\b
|
|
||||||
scope: markup.info.log
|
|
||||||
#- include: scope:text.html.markdown#autolink-inet
|
#- include: scope:text.html.markdown#autolink-inet
|
||||||
- match: \b\w+:/{2,3}
|
- match: \b\w+:/{2,3}
|
||||||
scope: markup.underline.link.scheme.log
|
scope: markup.underline.link.scheme.log
|
||||||
push: url-host
|
push: url-host
|
||||||
|
log_level_lines:
|
||||||
|
- match: ^(?=.*{{error}})
|
||||||
|
push:
|
||||||
|
- error_line
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: ^(?=.*{{warning}})
|
||||||
|
push:
|
||||||
|
- warning_line
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: ^(?=.*{{info}})
|
||||||
|
push:
|
||||||
|
- info_line
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: ^(?=.*{{debug}})
|
||||||
|
push:
|
||||||
|
- debug_line
|
||||||
|
- main_pop_at_eol
|
||||||
|
log_levels:
|
||||||
|
- match: '{{error}}'
|
||||||
|
scope: markup.error.log
|
||||||
|
- match: '{{warning}}'
|
||||||
|
scope: markup.warning.log
|
||||||
|
- match: '{{info}}'
|
||||||
|
scope: markup.info.log
|
||||||
|
- match: '{{debug}}'
|
||||||
|
scope: markup.info.log
|
||||||
|
error_line:
|
||||||
|
- meta_scope: meta.annotation.error-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
warning_line:
|
||||||
|
- meta_scope: meta.annotation.warning-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
info_line:
|
||||||
|
- meta_scope: meta.annotation.info-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
debug_line:
|
||||||
|
- meta_scope: meta.annotation.debug-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
immediately_pop:
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
pop_at_eol:
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
main_pop_at_eol:
|
||||||
|
- include: main_without_log_level_line
|
||||||
|
- include: pop_at_eol
|
||||||
dates:
|
dates:
|
||||||
- match: \b\d{4}-\d{2}-\d{2}(?=\b|T)
|
- match: \b\d{4}-\d{2}-\d{2}(?=\b|T)
|
||||||
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
@ -49,14 +98,12 @@ contexts:
|
|||||||
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
|
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
captures:
|
captures:
|
||||||
1: punctuation.separator.decimal.log
|
1: punctuation.separator.decimal.log
|
||||||
- match: ''
|
- include: immediately_pop
|
||||||
pop: true
|
|
||||||
maybe_date_time_separator:
|
maybe_date_time_separator:
|
||||||
- match: T(?={{hours_minutes_seconds}})
|
- match: T(?={{hours_minutes_seconds}})
|
||||||
scope: meta.date.log meta.time.log keyword.other.log
|
scope: meta.date.log meta.time.log keyword.other.log
|
||||||
set: time
|
set: time
|
||||||
- match: ''
|
- include: immediately_pop
|
||||||
pop: true
|
|
||||||
ip_addresses:
|
ip_addresses:
|
||||||
- match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
|
- match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
|
||||||
push:
|
push:
|
||||||
@ -65,8 +112,7 @@ contexts:
|
|||||||
scope: constant.numeric.value.log
|
scope: constant.numeric.value.log
|
||||||
- match: \.
|
- match: \.
|
||||||
scope: punctuation.separator.sequence.log
|
scope: punctuation.separator.sequence.log
|
||||||
- match: ''
|
- include: immediately_pop
|
||||||
pop: true
|
|
||||||
- match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
|
- match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
|
||||||
push:
|
push:
|
||||||
- meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
|
- meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
|
||||||
@ -74,8 +120,7 @@ contexts:
|
|||||||
scope: constant.numeric.value.log
|
scope: constant.numeric.value.log
|
||||||
- match: ':'
|
- match: ':'
|
||||||
scope: punctuation.separator.sequence.log
|
scope: punctuation.separator.sequence.log
|
||||||
- match: ''
|
- include: immediately_pop
|
||||||
pop: true
|
|
||||||
numbers:
|
numbers:
|
||||||
- match: \b(0x)(\h+)(?:(\.)(\h+))?\b
|
- match: \b(0x)(\h+)(?:(\.)(\h+))?\b
|
||||||
scope: meta.number.float.hexadecimal.log
|
scope: meta.number.float.hexadecimal.log
|
||||||
@ -127,8 +172,7 @@ contexts:
|
|||||||
pop: true
|
pop: true
|
||||||
- match: '[^?!.,:*_~\s<&()%]+|\S'
|
- match: '[^?!.,:*_~\s<&()%]+|\S'
|
||||||
scope: markup.underline.link.path.log
|
scope: markup.underline.link.path.log
|
||||||
- match: ''
|
- include: immediately_pop
|
||||||
pop: true
|
|
||||||
double_quoted_string:
|
double_quoted_string:
|
||||||
- meta_scope: string.quoted.double.log
|
- meta_scope: string.quoted.double.log
|
||||||
- match: \\"
|
- match: \\"
|
||||||
|
Loading…
Reference in New Issue
Block a user