Skip to content

Commit

Permalink
Simple access logos format implemented, closes #916
Browse files Browse the repository at this point in the history
  • Loading branch information
Sannis committed Aug 25, 2015
1 parent f9a6172 commit 56667e5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@ New languages:
- *Golo* by [Philippe Charrière][]
- *GAMS* by [Stefan Bechert][]
- *IRPF90* by [Anthony Scemama][]
- *Access logs* by [Oleg Efimov][]

Notable fixes and improvements to existing languages:

Expand All @@ -15,6 +16,7 @@ Notable fixes and improvements to existing languages:
[Philippe Charrière]: https://github.com/k33g
[Stefan Bechert]: https://github.com/b-pos465
[Anthony Scemama]: https://github.com/scemama
[Oleg Efimov]: https://github.com/Sannis

## Version 8.7

Expand Down
11 changes: 9 additions & 2 deletions docs/css-classes-reference.rst
Expand Up @@ -1503,7 +1503,7 @@ ARM assembler ("armasm", "arm")
* ``title``: symbol versions

AutoIt ("autoit")
-------------------------
-----------------

* ``keyword``: keyword
* ``literal``: True, False, And, Null, Not, Or
Expand All @@ -1513,4 +1513,11 @@ AutoIt ("autoit")
* ``string``: string
* ``comment``: comment
* ``number``: number
* ``preprocessor``: AutoIt3Wrapper directives section
* ``preprocessor``: AutoIt3Wrapper directives section

Access log ("accesslog")
------------------------

* ``keyword``: HTTP method name
* ``string``: date, request string, user-agent etc
* ``number``: IP-address, numbers
43 changes: 43 additions & 0 deletions src/languages/accesslog.js
@@ -0,0 +1,43 @@
/*
Language: Access log
Author: Oleg Efimov <efimovov@gmail.com>
Description: Apache/Nginx Access Logs
*/

function(hljs) {
return {
contains: [
// IP
{
className: 'number',
begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
},
// Other numbers
{
className: 'number',
begin: '\\b\\d+\\b',
relevance: 0
},
// Requests
{
className: 'string',
begin: '"(GET|POST|HEAD|PUT|DELETE|CONNECT|OPTIONS|PATCH|TRACE)', end: '"',
keywords: 'GET POST HEAD PUT DELETE CONNECT OPTIONS PATCH TRACE',
illegal: '\\n',
relevance: 10
},
// Dates
{
className: 'string',
begin: /\[/, end: /\]/,
illegal: '\\n'
},
// Strings
{
className: 'string',
begin: '"', end: '"',
illegal: '\\n'
}
]
};
}
1 change: 1 addition & 0 deletions test/detect/accesslog/default.txt
@@ -0,0 +1 @@
20.164.151.111 - - [20/Aug/2015:22:20:18 -0400] "GET /mywebpage/index.php HTTP/1.1" 403 772 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1"
1 change: 1 addition & 0 deletions test/markup/accesslog/default.expect.txt
@@ -0,0 +1 @@
<span class="hljs-number">20.164.151.111</span> - - <span class="hljs-string">[20/Aug/2015:22:20:18 -0400]</span> <span class="hljs-string">"<span class="hljs-keyword">GET</span> /mywebpage/index.php HTTP/1.1"</span> <span class="hljs-number">403</span> <span class="hljs-number">772</span> <span class="hljs-string">"-"</span> <span class="hljs-string">"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1"</span>
1 change: 1 addition & 0 deletions test/markup/accesslog/default.txt
@@ -0,0 +1 @@
20.164.151.111 - - [20/Aug/2015:22:20:18 -0400] "GET /mywebpage/index.php HTTP/1.1" 403 772 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1"

1 comment on commit 56667e5

@wreiske
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you!!

Please sign in to comment.