-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Generic log files (#2796)
- Loading branch information
1 parent
1a2347a
commit 2bc6475
Showing
28 changed files
with
4,071 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// This is a language definition for generic log files. | ||
// Since there is no one log format, this language definition has to support all formats to some degree. | ||
// | ||
// Based on https://github.com/MTDL9/vim-log-highlighting | ||
|
||
Prism.languages.log = { | ||
'string': { | ||
// Single-quoted strings must not be confused with plain text. E.g. Can't isn't Susan's Chris' toy | ||
pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?![st] | \w)(?:[^'\\\r\n]|\\.)*'/, | ||
greedy: true, | ||
}, | ||
|
||
'level': [ | ||
{ | ||
pattern: /\b(?:ALERT|CRIT|CRITICAL|EMERG|EMERGENCY|ERR|ERROR|FAILURE|FATAL|SEVERE)\b/, | ||
alias: ['error', 'important'] | ||
}, | ||
{ | ||
pattern: /\b(?:WARN|WARNING)\b/, | ||
alias: ['warning', 'important'] | ||
}, | ||
{ | ||
pattern: /\b(?:DISPLAY|INFO|NOTICE|STATUS)\b/, | ||
alias: ['info', 'keyword'] | ||
}, | ||
{ | ||
pattern: /\b(?:DEBUG|FINE)\b/, | ||
alias: ['debug', 'keyword'] | ||
}, | ||
{ | ||
pattern: /\b(?:FINER|FINEST|TRACE|VERBOSE)\b/, | ||
alias: ['trace', 'comment'] | ||
} | ||
], | ||
|
||
'property': { | ||
pattern: /((?:^|[\]|])[ \t]*)[a-z_](?:[\w-]|\b\/\b)*(?:[. ]\(?\w(?:[\w-]|\b\/\b)*\)?)*:(?=\s)/im, | ||
lookbehind: true | ||
}, | ||
|
||
'separator': { | ||
pattern: /(^|[^-+])-{3,}|={3,}|\*{3,}|- - /m, | ||
lookbehind: true, | ||
alias: 'comment' | ||
}, | ||
|
||
'url': /\b(?:https?|ftp|file):\/\/[^\s|,;'"]*[^\s|,;'">.]/, | ||
'email': { | ||
pattern: /(^|\s)[-\w+.]+@[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+(?=\s)/, | ||
lookbehind: true, | ||
alias: 'url' | ||
}, | ||
|
||
'ip-address': { | ||
pattern: /\b(?:\d{1,3}(?:\.\d{1,3}){3})\b/i, | ||
alias: 'constant' | ||
}, | ||
'mac-address': { | ||
pattern: /\b[a-f0-9]{2}(?::[a-f0-9]{2}){5}\b/i, | ||
alias: 'constant' | ||
}, | ||
'domain': { | ||
pattern: /(^|\s)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*\.[a-z][a-z0-9-]+(?=\s)/, | ||
lookbehind: true, | ||
alias: 'constant' | ||
}, | ||
|
||
'uuid': { | ||
pattern: /\b\w{8}-\w{4}-\w{4}-\w{4}-\w{12}\b/, | ||
alias: 'constant' | ||
}, | ||
'hash': { | ||
pattern: /\b(?:[a-f0-9]{32}){1,2}\b/i, | ||
alias: 'constant' | ||
}, | ||
|
||
'file-path': { | ||
pattern: /\b[a-z]:[\\/][^\s|,;:(){}\[\]"']+|(^|[\s:\[\](>|])\.{0,2}\/\w[^\s|,;:(){}\[\]"']*/i, | ||
lookbehind: true, | ||
greedy: true, | ||
alias: 'string' | ||
}, | ||
|
||
'date': { | ||
pattern: RegExp( | ||
/\b\d{4}[-/]\d{2}[-/]\d{2}T(?=\d{1,2}:)/.source + | ||
'|' + | ||
/\b\d{1,4}[-/ ](?:\d{1,2}|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[-/ ]\d{2,4}T?\b/.source + | ||
'|' + | ||
/\b(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:\s{1,2}(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))?|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s{1,2}\d{1,2}\b/.source, | ||
'i' | ||
), | ||
alias: 'number' | ||
}, | ||
'time': { | ||
pattern: /\b\d{1,2}:\d{1,2}:\d{1,2}(?:[.,:]\d+)?(?:\s?[+-]\d{2,4}|Z)?\b/, | ||
alias: 'number' | ||
}, | ||
|
||
'boolean': /\b(?:true|false|null)\b/i, | ||
'number': { | ||
pattern: /(^|[^.\w])(?:0x[a-f0-9]+|0o[0-7]+|0b[01]+|v?\d[\da-f]*(?:\.\d+)*(?:e[+-]?\d+)?[a-z]{0,3}\b)\b(?!\.\w)/i, | ||
lookbehind: true | ||
}, | ||
|
||
'operator': /[;:?<=>~/@!$%&+\-|^(){}*#]/, | ||
'punctuation': /[\[\].,]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h2>Nginx example</h2> | ||
<pre><code>/47.29.201.179 - - [28/Feb/2019:13:17:10 +0000] "GET /?p=1 HTTP/2.0" 200 5316 "https://domain1.com/?p=1" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" "2.75"</code></pre> | ||
<pre><code>Mar 19 22:10:18 xxxxxx journal: xxxxxxx.mylabserver.com nginx: photos.example.com 127.0.0.1 - - [19/Mar/2018:22:10:18 +0000] "GET / HTTP/1.1" 200 1863 "-" "curl/7.29.0" "-" | ||
Mar 19 22:10:24 xxxxxxx journal: xxxxxxxx.mylabserver.com nginx: photos.example.com 127.0.0.1 - - [19/Mar/2018:22:10:24 +0000] "GET / HTTP/1.1" 200 53324 "-" "curl/7.29.0" "-"</code></pre> | ||
<pre><code>TLSv1.2 AES128-SHA 1.1.1.1 "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" | ||
TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 2.2.2.2 "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1" | ||
TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 3.3.3.3 "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0" | ||
TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 4.4.4.4 "Mozilla/5.0 (Android 4.4.2; Tablet; rv:65.0) Gecko/65.0 Firefox/65.0" | ||
TLSv1 AES128-SHA 5.5.5.5 "Mozilla/5.0 (Android 4.4.2; Tablet; rv:65.0) Gecko/65.0 Firefox/65.0" | ||
TLSv1.2 ECDHE-RSA-CHACHA20-POLY1305 6.6.6.6 "Mozilla/5.0 (Linux; U; Android 5.0.2; en-US; XT1068 Build/LXB22.46-28) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.10.2.1164 Mobile Safari/537.36"</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.