1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function accesslog(hljs) {
|
12 | const regex = hljs.regex;
|
13 |
|
14 | const HTTP_VERBS = [
|
15 | "GET",
|
16 | "POST",
|
17 | "HEAD",
|
18 | "PUT",
|
19 | "DELETE",
|
20 | "CONNECT",
|
21 | "OPTIONS",
|
22 | "PATCH",
|
23 | "TRACE"
|
24 | ];
|
25 | return {
|
26 | name: 'Apache Access Log',
|
27 | contains: [
|
28 |
|
29 | {
|
30 | className: 'number',
|
31 | begin: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?\b/,
|
32 | relevance: 5
|
33 | },
|
34 |
|
35 | {
|
36 | className: 'number',
|
37 | begin: /\b\d+\b/,
|
38 | relevance: 0
|
39 | },
|
40 |
|
41 | {
|
42 | className: 'string',
|
43 | begin: regex.concat(/"/, regex.either(...HTTP_VERBS)),
|
44 | end: /"/,
|
45 | keywords: HTTP_VERBS,
|
46 | illegal: /\n/,
|
47 | relevance: 5,
|
48 | contains: [
|
49 | {
|
50 | begin: /HTTP\/[12]\.\d'/,
|
51 | relevance: 5
|
52 | }
|
53 | ]
|
54 | },
|
55 |
|
56 | {
|
57 | className: 'string',
|
58 |
|
59 |
|
60 |
|
61 | begin: /\[\d[^\]\n]{8,}\]/,
|
62 | illegal: /\n/,
|
63 | relevance: 1
|
64 | },
|
65 | {
|
66 | className: 'string',
|
67 | begin: /\[/,
|
68 | end: /\]/,
|
69 | illegal: /\n/,
|
70 | relevance: 0
|
71 | },
|
72 |
|
73 | {
|
74 | className: 'string',
|
75 | begin: /"Mozilla\/\d\.\d \(/,
|
76 | end: /"/,
|
77 | illegal: /\n/,
|
78 | relevance: 3
|
79 | },
|
80 |
|
81 | {
|
82 | className: 'string',
|
83 | begin: /"/,
|
84 | end: /"/,
|
85 | illegal: /\n/,
|
86 | relevance: 0
|
87 | }
|
88 | ]
|
89 | };
|
90 | }
|
91 |
|
92 | export { accesslog as default };
|