Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Syslog and general log file highlighting #1606

Merged
merged 7 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

## Syntaxes

- Improved the Syslog syntax highlighting, see #1606 (@keith-hall)

## New themes

## `bat` as a library
Expand Down
1 change: 0 additions & 1 deletion assets/syntaxes/02_Extra/Syslog
Submodule Syslog deleted from 7628d4
70 changes: 70 additions & 0 deletions assets/syntaxes/02_Extra/syslog.sublime-syntax
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/syntax-tests/highlighted/Syslog/example.syslog
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 5 additions & 0 deletions tests/syntax-tests/source/Syslog/example.syslog
Original file line number Diff line number Diff line change
@@ -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'