2021-04-06 23:50:52 +03:00
%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]?)
2022-03-21 20:00:58 +02:00
hours_minutes_seconds : (?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)
2022-04-10 00:28:43 +03:00
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
2021-04-06 23:50:52 +03:00
contexts :
main :
2022-04-10 00:28:43 +03:00
- include : log_level_lines
- include : main_without_log_level_line
main_without_log_level_line :
2021-04-06 23:50:52 +03:00
- 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
2022-03-21 20:00:58 +02:00
- match : \"
2021-04-06 23:50:52 +03:00
captures :
1 : punctuation.definition.string.begin.log
2022-03-21 20:00:58 +02:00
push : double_quoted_string
2021-04-06 23:50:52 +03:00
- include : dates
- include : ip_addresses
- include : numbers
2022-04-10 00:28:43 +03:00
- include : log_levels
2021-04-06 23:50:52 +03:00
#- include: scope:text.html.markdown#autolink-inet
- match : \b\w+:/{2,3}
scope : markup.underline.link.scheme.log
push : url-host
2022-04-10 00:28:43 +03:00
log_level_lines :
2026-08-02 10:52:05 +03:00
# Prevent retrying each lookahead at every position.
2026-08-10 20:00:44 +03:00
- match : ^(?=.*{{error}})
2022-04-10 00:28:43 +03:00
push :
2025-02-08 21:06:33 +02:00
- error_line_meta
2022-04-10 00:28:43 +03:00
- main_pop_at_eol
2026-08-10 20:00:44 +03:00
- match : ^(?=.*{{warning}})
2022-04-10 00:28:43 +03:00
push :
2025-02-08 21:06:33 +02:00
- warning_line_meta
2022-04-10 00:28:43 +03:00
- main_pop_at_eol
2026-08-10 20:00:44 +03:00
- match : ^(?=.*{{info}})
2022-04-10 00:28:43 +03:00
push :
2025-02-08 21:06:33 +02:00
- info_line_meta
2022-04-10 00:28:43 +03:00
- main_pop_at_eol
2026-08-10 20:00:44 +03:00
- match : ^(?=.*{{debug}})
2022-04-10 00:28:43 +03:00
push :
2025-02-08 21:06:33 +02:00
- debug_line_meta
2022-04-10 00:28:43 +03:00
- main_pop_at_eol
2026-08-10 20:56:35 +03:00
# For syntaxes that embed Log after consuming a prefix. Call this context once.
log_level_lines_at_current_position :
- match : (?=.*{{error}})
set :
- error_line_meta
- main_pop_at_eol
- match : (?=.*{{warning}})
set :
- warning_line_meta
- main_pop_at_eol
- match : (?=.*{{info}})
set :
- info_line_meta
- main_pop_at_eol
- match : (?=.*{{debug}})
set :
- debug_line_meta
- main_pop_at_eol
2022-04-10 00:28:43 +03:00
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
2025-02-08 21:06:33 +02:00
error_line_meta :
2022-04-10 00:28:43 +03:00
- meta_scope : meta.annotation.error-line.log
- include : immediately_pop
2025-02-08 21:06:33 +02:00
warning_line_meta :
2022-04-10 00:28:43 +03:00
- meta_scope : meta.annotation.warning-line.log
- include : immediately_pop
2025-02-08 21:06:33 +02:00
info_line_meta :
2022-04-10 00:28:43 +03:00
- meta_scope : meta.annotation.info-line.log
- include : immediately_pop
2025-02-08 21:06:33 +02:00
debug_line_meta :
2022-04-10 00:28:43 +03:00
- 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
2021-04-06 23:50:52 +03:00
dates :
2022-03-21 20:00:58 +02:00
- match : \b\d{4}-\d{2}-\d{2}(?=\b|T)
2021-04-06 23:50:52 +03:00
scope : meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
2022-03-21 20:00:58 +02:00
push : maybe_date_time_separator
- match : \b\d{4}/\d{2}/\d{2}(?=\b|T)
2021-04-06 23:50:52 +03:00
scope : meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
2022-03-21 20:00:58 +02:00
push : maybe_date_time_separator
- match : \b(?={{hours_minutes_seconds}})
push : time
time :
- match : (?:{{hours_minutes_seconds}})(?:(\.)\d{3})?\b
2021-04-06 23:50:52 +03:00
scope : meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
captures :
1 : punctuation.separator.decimal.log
2022-04-10 00:28:43 +03:00
- include : immediately_pop
2022-03-21 20:00:58 +02:00
maybe_date_time_separator :
- match : T(?={{hours_minutes_seconds}})
scope : meta.date.log meta.time.log keyword.other.log
set : time
2022-04-10 00:28:43 +03:00
- include : immediately_pop
2021-04-06 23:50:52 +03:00
ip_addresses :
2021-04-07 22:01:10 +03:00
- match : \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
2021-04-06 23:50:52 +03:00
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
2022-04-10 00:28:43 +03:00
- include : immediately_pop
2021-04-07 22:01:10 +03:00
- match : (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
2021-04-06 23:50:52 +03:00
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
2022-04-10 00:28:43 +03:00
- include : immediately_pop
2021-04-06 23:50:52 +03:00
numbers :
2021-04-07 22:01:10 +03:00
- match : \b(0x)(\h+)(?:(\.)(\h+))?\b
2021-04-06 23:50:52 +03:00
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
2022-04-10 00:28:43 +03:00
- include : immediately_pop
2022-03-21 20:00:58 +02:00
double_quoted_string :
- meta_scope : string.quoted.double.log
- match : \\"
scope : constant.character.escape.log
- match : \\n
scope : constant.character.escape.log
- match : \"
scope : punctuation.definition.string.end.log
pop : true