source: node_modules/refractor/lang/log.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[d24f17c]1'use strict'
2
3module.exports = log
4log.displayName = 'log'
5log.aliases = []
6function log(Prism) {
7 // This is a language definition for generic log files.
8 // Since there is no one log format, this language definition has to support all formats to some degree.
9 //
10 // Based on https://github.com/MTDL9/vim-log-highlighting
11 Prism.languages.log = {
12 string: {
13 // Single-quoted strings must not be confused with plain text. E.g. Can't isn't Susan's Chris' toy
14 pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?![st] | \w)(?:[^'\\\r\n]|\\.)*'/,
15 greedy: true
16 },
17 exception: {
18 pattern:
19 /(^|[^\w.])[a-z][\w.]*(?:Error|Exception):.*(?:(?:\r\n?|\n)[ \t]*(?:at[ \t].+|\.{3}.*|Caused by:.*))+(?:(?:\r\n?|\n)[ \t]*\.\.\. .*)?/,
20 lookbehind: true,
21 greedy: true,
22 alias: ['javastacktrace', 'language-javastacktrace'],
23 inside: Prism.languages['javastacktrace'] || {
24 keyword: /\bat\b/,
25 function: /[a-z_][\w$]*(?=\()/,
26 punctuation: /[.:()]/
27 }
28 },
29 level: [
30 {
31 pattern:
32 /\b(?:ALERT|CRIT|CRITICAL|EMERG|EMERGENCY|ERR|ERROR|FAILURE|FATAL|SEVERE)\b/,
33 alias: ['error', 'important']
34 },
35 {
36 pattern: /\b(?:WARN|WARNING|WRN)\b/,
37 alias: ['warning', 'important']
38 },
39 {
40 pattern: /\b(?:DISPLAY|INF|INFO|NOTICE|STATUS)\b/,
41 alias: ['info', 'keyword']
42 },
43 {
44 pattern: /\b(?:DBG|DEBUG|FINE)\b/,
45 alias: ['debug', 'keyword']
46 },
47 {
48 pattern: /\b(?:FINER|FINEST|TRACE|TRC|VERBOSE|VRB)\b/,
49 alias: ['trace', 'comment']
50 }
51 ],
52 property: {
53 pattern:
54 /((?:^|[\]|])[ \t]*)[a-z_](?:[\w-]|\b\/\b)*(?:[. ]\(?\w(?:[\w-]|\b\/\b)*\)?)*:(?=\s)/im,
55 lookbehind: true
56 },
57 separator: {
58 pattern: /(^|[^-+])-{3,}|={3,}|\*{3,}|- - /m,
59 lookbehind: true,
60 alias: 'comment'
61 },
62 url: /\b(?:file|ftp|https?):\/\/[^\s|,;'"]*[^\s|,;'">.]/,
63 email: {
64 pattern: /(^|\s)[-\w+.]+@[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+(?=\s)/,
65 lookbehind: true,
66 alias: 'url'
67 },
68 'ip-address': {
69 pattern: /\b(?:\d{1,3}(?:\.\d{1,3}){3})\b/,
70 alias: 'constant'
71 },
72 'mac-address': {
73 pattern: /\b[a-f0-9]{2}(?::[a-f0-9]{2}){5}\b/i,
74 alias: 'constant'
75 },
76 domain: {
77 pattern:
78 /(^|\s)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*\.[a-z][a-z0-9-]+(?=\s)/,
79 lookbehind: true,
80 alias: 'constant'
81 },
82 uuid: {
83 pattern:
84 /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i,
85 alias: 'constant'
86 },
87 hash: {
88 pattern: /\b(?:[a-f0-9]{32}){1,2}\b/i,
89 alias: 'constant'
90 },
91 'file-path': {
92 pattern:
93 /\b[a-z]:[\\/][^\s|,;:(){}\[\]"']+|(^|[\s:\[\](>|])\.{0,2}\/\w[^\s|,;:(){}\[\]"']*/i,
94 lookbehind: true,
95 greedy: true,
96 alias: 'string'
97 },
98 date: {
99 pattern: RegExp(
100 /\b\d{4}[-/]\d{2}[-/]\d{2}(?:T(?=\d{1,2}:)|(?=\s\d{1,2}:))/.source +
101 '|' +
102 /\b\d{1,4}[-/ ](?:\d{1,2}|Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep)[-/ ]\d{2,4}T?\b/
103 .source +
104 '|' +
105 /\b(?:(?:Fri|Mon|Sat|Sun|Thu|Tue|Wed)(?:\s{1,2}(?:Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep))?|Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep)\s{1,2}\d{1,2}\b/
106 .source,
107 'i'
108 ),
109 alias: 'number'
110 },
111 time: {
112 pattern:
113 /\b\d{1,2}:\d{1,2}:\d{1,2}(?:[.,:]\d+)?(?:\s?[+-]\d{2}:?\d{2}|Z)?\b/,
114 alias: 'number'
115 },
116 boolean: /\b(?:false|null|true)\b/i,
117 number: {
118 pattern:
119 /(^|[^.\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,
120 lookbehind: true
121 },
122 operator: /[;:?<=>~/@!$%&+\-|^(){}*#]/,
123 punctuation: /[\[\].,]/
124 }
125}
Note: See TracBrowser for help on using the repository browser.