From ba0d43672b783d4a7195b21bfb378e7ba0c4d6ab Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 4 Apr 2021 22:41:48 +0300 Subject: add example syslog file for highlighting tests --- tests/syntax-tests/source/Syslog/example.syslog | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/syntax-tests/source/Syslog/example.syslog diff --git a/tests/syntax-tests/source/Syslog/example.syslog b/tests/syntax-tests/source/Syslog/example.syslog new file mode 100644 index 00000000..944bd7dd --- /dev/null +++ b/tests/syntax-tests/source/Syslog/example.syslog @@ -0,0 +1,5 @@ +Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded. +Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files. +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" +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) +Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid' -- cgit v1.2.3 From 1537733e6b0d764e092b701565de94c51ef3ecf1 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 4 Apr 2021 22:42:13 +0300 Subject: replace Syslog dependency with a custom syntax --- .gitmodules | 4 -- CHANGELOG.md | 2 + assets/syntaxes/02_Extra/Syslog | 1 - assets/syntaxes/02_Extra/syslog.sublime-syntax | 70 ++++++++++++++++++++++ .../syntax-tests/highlighted/Syslog/example.syslog | 5 ++ 5 files changed, 77 insertions(+), 5 deletions(-) delete mode 160000 assets/syntaxes/02_Extra/Syslog create mode 100644 assets/syntaxes/02_Extra/syslog.sublime-syntax create mode 100644 tests/syntax-tests/highlighted/Syslog/example.syslog diff --git a/.gitmodules b/.gitmodules index 4b6bc34e..5cafb38e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -97,10 +97,6 @@ [submodule "assets/syntaxes/Assembly (ARM)"] path = assets/syntaxes/02_Extra/Assembly (ARM) url = https://github.com/tvi/Sublime-ARM-Assembly -[submodule "assets/syntaxes/syslog-syntax"] - path = assets/syntaxes/02_Extra/Syslog - url = https://github.com/caos21/syslog-syntax.git - branch = master [submodule "assets/syntaxes/protobuf-syntax-highlighting"] path = assets/syntaxes/02_Extra/Protobuf url = https://github.com/VcamX/protobuf-syntax-highlighting.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b02eb41..75e73ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ## Syntaxes +- Improved the Syslog syntax highlighting, see #1606 (@keith-hall) + ## New themes ## `bat` as a library diff --git a/assets/syntaxes/02_Extra/Syslog b/assets/syntaxes/02_Extra/Syslog deleted file mode 160000 index 7628d4e0..00000000 --- a/assets/syntaxes/02_Extra/Syslog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7628d4e0b89d3b4f0dcc014bfb4a3e3433f5133a diff --git a/assets/syntaxes/02_Extra/syslog.sublime-syntax b/assets/syntaxes/02_Extra/syslog.sublime-syntax new file mode 100644 index 00000000..6233da17 --- /dev/null +++ b/assets/syntaxes/02_Extra/syslog.sublime-syntax @@ -0,0 +1,70 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: syslog +file_extensions: + - syslog +scope: text.syslog +contexts: + main: + - match: '^\w+\s+\d+\s+\d{2}:\d{2}:\d{2}' + scope: meta.datetime.syslog constant.numeric.syslog + push: loghost + loghost: + - match: '[\w-]+' + scope: entity.other.attribute-name.loghost.syslog + set: process + process: + - match: ([\w-]+)(?:(\[)(\d+)(\]))?(:) + captures: + 1: support.function.process.syslog + 2: punctuation.separator.pid.begin.syslog + 3: meta.pid.syslog meta.number.integer.syslog constant.numeric.value.syslog + 4: punctuation.separator.mapping.syslog + set: structured-data + structured-data: + - match: '\[' + scope: punctuation.section.mapping.begin.syslog + push: + - match: \] + scope: punctuation.section.mapping.end.syslog + pop: true + - match: \w+ + scope: variable.parameter.syslog + - match: = + scope: keyword.operator.assignment.syslog + push: + - match: '[^\s\]]+' + scope: constant.other.syslog + pop: true + - match: (?=\]) + pop: true + - match: (?=\S) + set: text + text: + - match: (\w+)(=) + captures: + 1: variable.parameter.syslog + 2: keyword.operator.assignment.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 + - match: \d+ + scope: meta.number.integer.syslog constant.numeric.value.syslog + - match: \b(CMD)\b\s+(\() + captures: + 1: entity.name.label.syslog + 2: punctuation.section.block.begin.syslog + embed: scope:source.shell.bash + escape: \) + escape_captures: + 0: punctuation.section.block.end.syslog + - match: $ + pop: true diff --git a/tests/syntax-tests/highlighted/Syslog/example.syslog b/tests/syntax-tests/highlighted/Syslog/example.syslog new file mode 100644 index 00000000..5ea6d9eb --- /dev/null +++ b/tests/syntax-tests/highlighted/Syslog/example.syslog @@ -0,0 +1,5 @@ +Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded. +Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files. +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" +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) +Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid' -- cgit v1.2.3 From 782ede5db5ad601e44468c9ca32bd201e5c75aaa Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Mon, 5 Apr 2021 22:17:47 +0300 Subject: improve syslog syntax --- assets/syntaxes/02_Extra/syslog.sublime-syntax | 51 +++++++++++++++++++--- .../syntax-tests/highlighted/Syslog/example.syslog | 16 ++++--- tests/syntax-tests/source/Syslog/example.syslog | 6 +++ 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/assets/syntaxes/02_Extra/syslog.sublime-syntax b/assets/syntaxes/02_Extra/syslog.sublime-syntax index 6233da17..9b243c9c 100644 --- a/assets/syntaxes/02_Extra/syslog.sublime-syntax +++ b/assets/syntaxes/02_Extra/syslog.sublime-syntax @@ -5,10 +5,15 @@ name: syslog file_extensions: - syslog scope: text.syslog +variables: + ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) contexts: main: - - match: '^\w+\s+\d+\s+\d{2}:\d{2}:\d{2}' + - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2}) scope: meta.datetime.syslog constant.numeric.syslog + captures: + 1: meta.date.syslog + 2: meta.time.syslog push: loghost loghost: - match: '[\w-]+' @@ -20,7 +25,8 @@ contexts: 1: support.function.process.syslog 2: punctuation.separator.pid.begin.syslog 3: meta.pid.syslog meta.number.integer.syslog constant.numeric.value.syslog - 4: punctuation.separator.mapping.syslog + 4: punctuation.separator.pid.end.syslog + 5: punctuation.separator.mapping.syslog set: structured-data structured-data: - match: '\[' @@ -56,15 +62,50 @@ contexts: captures: 1: punctuation.definition.string.begin.syslog 3: punctuation.definition.string.end.syslog - - match: \d+ - scope: meta.number.integer.syslog constant.numeric.value.syslog + - include: numbers - match: \b(CMD)\b\s+(\() captures: 1: entity.name.label.syslog 2: punctuation.section.block.begin.syslog embed: scope:source.shell.bash - escape: \) + escape: \)$ escape_captures: 0: punctuation.section.block.end.syslog + - match: '<\w+>' + 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 diff --git a/tests/syntax-tests/highlighted/Syslog/example.syslog b/tests/syntax-tests/highlighted/Syslog/example.syslog index 5ea6d9eb..35002a83 100644 --- a/tests/syntax-tests/highlighted/Syslog/example.syslog +++ b/tests/syntax-tests/highlighted/Syslog/example.syslog @@ -1,5 +1,11 @@ -Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded. -Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files. -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" -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) -Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid' +Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded. +Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files. +Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available +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" +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. +Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37 +Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 ->  +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 +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) +Apr 4 16:32:07 hostname-here NetworkManager[740]:  [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL +Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid' diff --git a/tests/syntax-tests/source/Syslog/example.syslog b/tests/syntax-tests/source/Syslog/example.syslog index 944bd7dd..337f1434 100644 --- a/tests/syntax-tests/source/Syslog/example.syslog +++ b/tests/syntax-tests/source/Syslog/example.syslog @@ -1,5 +1,11 @@ Apr 4 00:00:01 hostname-here systemd[1]: logrotate.service: Succeeded. Apr 4 00:00:01 hostname-here systemd[1]: Finished Rotate log files. +Apr 4 00:00:01 hostname-here colord[920]: failed to get session [pid 137485]: No data available 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" +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. +Apr 4 00:04:46 hostname-here ntpd[952]: Soliciting pool server 255.76.59.37 +Apr 4 00:05:21 hostname-here ntpd[952]: ::1 local addr 0:0:0:0:0:0:0:1 -> +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 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) +Apr 4 16:32:07 hostname-here NetworkManager[740]: [1617629527.1101] manager: NetworkManager state is now CONNECTED_GLOBAL Apr 4 22:00:45 hostname-here dbus-daemon[1094]: [session uid=1000 pid=1094] Successfully activated service 'io.github.celluloid_player.Celluloid' -- cgit v1.2.3 From 7c4edacb2be13eef3afe0e2b23fb83c7ca813dd7 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 6 Apr 2021 23:50:52 +0300 Subject: Add independent log syntax --- assets/syntaxes/02_Extra/log.sublime-syntax | 114 +++++++++++++++++++++++++ assets/syntaxes/02_Extra/syslog.sublime-syntax | 62 ++------------ tests/syntax-tests/highlighted/Log/example.log | 2 + tests/syntax-tests/source/Log/example.log | 2 + 4 files changed, 125 insertions(+), 55 deletions(-) create mode 100644 assets/syntaxes/02_Extra/log.sublime-syntax create mode 100644 tests/syntax-tests/highlighted/Log/example.log create mode 100644 tests/syntax-tests/source/Log/example.log diff --git a/assets/syntaxes/02_Extra/log.sublime-syntax b/assets/syntaxes/02_Extra/log.sublime-syntax new file mode 100644 index 00000000..2c961008 --- /dev/null +++ b/assets/syntaxes/02_Extra/log.sublime-syntax @@ -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 diff --git a/assets/syntaxes/02_Extra/syslog.sublime-syntax b/assets/syntaxes/02_Extra/syslog.sublime-syntax index 9b243c9c..23730b70 100644 --- a/assets/syntaxes/02_Extra/syslog.sublime-syntax +++ b/assets/syntaxes/02_Extra/syslog.sublime-syntax @@ -5,8 +5,6 @@ name: syslog file_extensions: - syslog scope: text.syslog -variables: - ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) contexts: main: - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2}) @@ -15,6 +13,8 @@ contexts: 1: meta.date.syslog 2: meta.time.syslog push: loghost + - match: ^ + push: text loghost: - match: '[\w-]+' scope: entity.other.attribute-name.loghost.syslog @@ -48,21 +48,10 @@ contexts: - match: (?=\S) set: text text: - - match: (\w+)(=) - captures: - 1: variable.parameter.syslog - 2: keyword.operator.assignment.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: $ + pop: true + - match: '<\w+>' + scope: constant.language.syslog - match: \b(CMD)\b\s+(\() captures: 1: entity.name.label.syslog @@ -71,41 +60,4 @@ contexts: escape: \)$ escape_captures: 0: punctuation.section.block.end.syslog - - match: '<\w+>' - 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 + - include: scope:text.log diff --git a/tests/syntax-tests/highlighted/Log/example.log b/tests/syntax-tests/highlighted/Log/example.log new file mode 100644 index 00000000..8387670c --- /dev/null +++ b/tests/syntax-tests/highlighted/Log/example.log @@ -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 diff --git a/tests/syntax-tests/source/Log/example.log b/tests/syntax-tests/source/Log/example.log new file mode 100644 index 00000000..35eb1c78 --- /dev/null +++ b/tests/syntax-tests/source/Log/example.log @@ -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 -- cgit v1.2.3 From 867cf63dd9db70adad65f4e8a9ac38a4fce352e9 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Wed, 7 Apr 2021 22:01:10 +0300 Subject: add word boundaries to log syntax highlighting --- assets/syntaxes/02_Extra/log.sublime-syntax | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/syntaxes/02_Extra/log.sublime-syntax b/assets/syntaxes/02_Extra/log.sublime-syntax index 2c961008..5e4501b8 100644 --- a/assets/syntaxes/02_Extra/log.sublime-syntax +++ b/assets/syntaxes/02_Extra/log.sublime-syntax @@ -25,7 +25,7 @@ contexts: - include: dates - include: ip_addresses - include: numbers - - match: \b(?i:fail(?:ure|ed)?|error)\b + - match: \b(?i:fail(?:ure|ed)?|error|exception)\b scope: invalid.illegal.error.log #- include: scope:text.html.markdown#autolink-inet - match: \b\w+:/{2,3} @@ -41,7 +41,7 @@ contexts: captures: 1: punctuation.separator.decimal.log ip_addresses: - - match: (?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}) + - match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b) push: - meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log - match: \d+ @@ -50,7 +50,7 @@ contexts: scope: punctuation.separator.sequence.log - match: '' pop: true - - match: (?=(?:\h{0,4}:){2,6}\h{1,4}) + - match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b) push: - meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log - match: \h{1,4} @@ -60,7 +60,7 @@ contexts: - match: '' pop: true numbers: - - match: (0x)(\h+)(?:(\.)(\h+))? + - match: \b(0x)(\h+)(?:(\.)(\h+))?\b scope: meta.number.float.hexadecimal.log captures: 1: constant.numeric.base.log -- cgit v1.2.3 From b3ab8439547b6204167cb05ac7360160b54a1568 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Fri, 9 Apr 2021 22:09:01 +0300 Subject: add warning highlighting to log file syntax definition --- assets/patches/Monokai-Extended.tmTheme.patch | 18 ++++++++++++++++++ assets/syntaxes/02_Extra/log.sublime-syntax | 4 +++- assets/syntaxes/02_Extra/syslog.sublime-syntax | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/patches/Monokai-Extended.tmTheme.patch b/assets/patches/Monokai-Extended.tmTheme.patch index 24573a7b..c237f53d 100644 --- a/assets/patches/Monokai-Extended.tmTheme.patch +++ b/assets/patches/Monokai-Extended.tmTheme.patch @@ -16,3 +16,21 @@ index 9c2aa3e..180cbbf 100644 +@@ -1027,7 +1027,7 @@ + name + Invalid + scope +- invalid ++ invalid, markup.error + settings + + background +@@ -1042,7 +1042,7 @@ + name + Invalid deprecated + scope +- invalid.deprecated ++ invalid.deprecated, markup.warning + settings + + background diff --git a/assets/syntaxes/02_Extra/log.sublime-syntax b/assets/syntaxes/02_Extra/log.sublime-syntax index 5e4501b8..3c699d2e 100644 --- a/assets/syntaxes/02_Extra/log.sublime-syntax +++ b/assets/syntaxes/02_Extra/log.sublime-syntax @@ -26,7 +26,9 @@ contexts: - include: ip_addresses - include: numbers - match: \b(?i:fail(?:ure|ed)?|error|exception)\b - scope: invalid.illegal.error.log + scope: markup.error.log + - match: \b(?i:warn(?:ing)?)\b + scope: markup.warning.log #- include: scope:text.html.markdown#autolink-inet - match: \b\w+:/{2,3} scope: markup.underline.link.scheme.log diff --git a/assets/syntaxes/02_Extra/syslog.sublime-syntax b/assets/syntaxes/02_Extra/syslog.sublime-syntax index 23730b70..ce782e50 100644 --- a/assets/syntaxes/02_Extra/syslog.sublime-syntax +++ b/assets/syntaxes/02_Extra/syslog.sublime-syntax @@ -4,7 +4,7 @@ name: syslog file_extensions: - syslog -scope: text.syslog +scope: text.log.syslog contexts: main: - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2}) -- cgit v1.2.3