Merge pull request #2127 from sharkdp/log_syntax_2123

Syntax: [Log] highlight escape characters in double quoted strings
This commit is contained in:
Keith Hall 2022-03-23 22:37:44 +02:00 committed by GitHub
commit 1b030dc03b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 9 deletions

View file

@ -13,6 +13,7 @@
## Syntaxes
- Mapped clang-format config file (.clang-format) to YAML syntax (@TruncatedDinosour)
- log syntax: improved handling of escape characters in double quoted strings. See #2123 (@keith-hall)
## Themes

View file

@ -6,6 +6,7 @@ file_extensions:
scope: text.log
variables:
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)
contexts:
main:
- match: (\w+)(=)
@ -17,11 +18,10 @@ contexts:
captures:
1: punctuation.definition.string.begin.log
3: punctuation.definition.string.end.log
- match: (")([^"]*)(")
scope: string.quoted.double.log
- match: \"
captures:
1: punctuation.definition.string.begin.log
3: punctuation.definition.string.end.log
push: double_quoted_string
- include: dates
- include: ip_addresses
- include: numbers
@ -29,19 +29,34 @@ contexts:
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
- match: \b\w+:/{2,3}
scope: markup.underline.link.scheme.log
push: url-host
dates:
- match: \b\d{4}-\d{2}-\d{2}\b
- match: \b\d{4}-\d{2}-\d{2}(?=\b|T)
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
- match: \b\d{4}/\d{2}/\d{2}\b
push: maybe_date_time_separator
- match: \b\d{4}/\d{2}/\d{2}(?=\b|T)
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
push: maybe_date_time_separator
- match: \b(?={{hours_minutes_seconds}})
push: time
time:
- match: (?:{{hours_minutes_seconds}})(?:(\.)\d{3})?\b
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
captures:
1: punctuation.separator.decimal.log
- match: ''
pop: true
maybe_date_time_separator:
- match: T(?={{hours_minutes_seconds}})
scope: meta.date.log meta.time.log keyword.other.log
set: time
- match: ''
pop: true
ip_addresses:
- match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
push:
@ -114,3 +129,12 @@ contexts:
scope: markup.underline.link.path.log
- match: ''
pop: true
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

View file

@ -1,2 +1,3 @@
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
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }

View file

@ -1,7 +1,7 @@
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: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 -> <null>
@ -10,7 +10,7 @@
Apr 4 16:32:07 hostname-here NetworkManager[740]: <info> [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'
Aug 11 13:29:06 hostname-here insomnia_insomnia.desktop[142666]: 13:29:06.316 [updater] Updater not running platform=linux dev=false
Aug 11 13:36:34 192.168.220.5 nginx: 2021/08/11 13:36:34 [debug] 2031#2031: epoll add event: fd:6 op:1 ev:00002001
Aug 11 21:31:08 ::1 nginx: 2021/08/11 21:31:08 [debug] 760831#760831: epoll add event: fd:6 op:1 ev:10000001
Aug 11 13:36:34 192.168.220.5 nginx: 2021/08/11 13:36:34 [debug] 2031#2031: epoll add event: fd:6 op:1 ev:00002001
Aug 11 21:31:08 ::1 nginx: 2021/08/11 21:31:08 [debug] 760831#760831: epoll add event: fd:6 op:1 ev:10000001
Aug 11 21:40:31 hostname-here scop hello
Aug 16 21:38:21 hostname-here systemd[1]: Finished Cleanup of Temporary Directories.

View file

@ -1,2 +1,3 @@
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
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }