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

add log_file highlighter #4501

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions demo/kitchen-sink/docs/log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
2019-04-05T04:33:43.910+04:00 2019-04-05T12:33:43.909Z 05403d5c-0850-4d0d-9948-aa3ccc23410b Loading function
2019-04-05T04:33:43.925+04:00 START RequestId: 05403d5c-0850-4d0d-9948-aa3ccc23410b Version: $LATEST
2019-04-05T04:33:43.928+04:00 2019-04-05T12:33:43.927Z 05403d5c-0850-4d0d-9948-aa3ccc23410b value1 = undefined
2019-04-05T04:33:43.928+04:00 2019-04-05T12:33:43.928Z 05403d5c-0850-4d0d-9948-aa3ccc23410b value2 = undefined
2019-04-05T04:33:43.928+04:00 2019-04-05T12:33:43.928Z 05403d5c-0850-4d0d-9948-aa3ccc23410b value3 = undefined
2019-04-05T04:33:43.928+04:00 2019-04-05T12:33:43.928Z 05403d5c-0850-4d0d-9948-aa3ccc23410b test
2019-04-05T04:33:43.965+04:00 END RequestId: 05403d5c-0850-4d0d-9948-aa3ccc23410b
2019-04-05T04:33:43.965+04:00 REPORT RequestId: 05403d5c-0850-4d0d-9948-aa3ccc23410b Duration: 18.03 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 42 MB
2019-04-05T04:34:23.163+04:00 START RequestId: 76df9838-7461-4ede-9736-abce59722f3f Version: $LATEST
2019-04-05T04:34:23.165+04:00 2019-04-05T12:34:23.165Z 76df9838-7461-4ede-9736-abce59722f3f value1 = undefined
2019-04-05T04:34:23.165+04:00 2019-04-05T12:34:23.165Z 76df9838-7461-4ede-9736-abce59722f3f value2 = undefined
2019-04-05T04:34:23.165+04:00 2019-04-05T12:34:23.165Z 76df9838-7461-4ede-9736-abce59722f3f value3 = undefined
2019-04-05T04:34:23.165+04:00 2019-04-05T12:34:23.165Z 76df9838-7461-4ede-9736-abce59722f3f test
2019-04-05T04:34:23.165+04:00 END RequestId: 76df9838-7461-4ede-9736-abce59722f3f
2019-04-05T04:34:23.165+04:00 REPORT RequestId: 76df9838-7461-4ede-9736-abce59722f3f Duration: 0.82 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 42 MB
1 change: 1 addition & 0 deletions lib/ace/ext/modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ var supportedModes = {
Liquid: ["liquid"],
Lisp: ["lisp"],
LiveScript: ["ls"],
Log: ["log"],
LogiQL: ["logic|lql"],
LSL: ["lsl"],
Lua: ["lua"],
Expand Down
54 changes: 54 additions & 0 deletions lib/ace/mode/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */

/*
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
*/

define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var LogHighlightRules = require("./log_highlight_rules").LogHighlightRules;
var FoldMode = require("./folding/cstyle").FoldMode;

var Mode = function() {
this.HighlightRules = LogHighlightRules;
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);

(function() {
this.$id = "ace/mode/log";
}).call(Mode.prototype);

exports.Mode = Mode;
});
160 changes: 160 additions & 0 deletions lib/ace/mode/log_highlight_rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */

/* This file was autogenerated from https://raw.githubusercontent.com/emilast/vscode-logfile-highlighter/master/syntaxes/log.tmLanguage (uuid: ) */

define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var LogHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used

this.$rules = {
start: [{
token: "comment log.verbose",
regex: /\bTrace\b:/
}, {
token: "comment log.verbose",
regex: /\[(?:verbose|verb|vrb|vb|v)\]/,
caseInsensitive: true
}, {
token: "comment log.verbose",
regex: /(?<=^[\s\d\p]*)\bV\b/
}, {
token: "markup.changed log.debug",
regex: /\b(?:DEBUG|Debug)\b|\bdebug\:/,
caseInsensitive: true
}, {
token: "markup.changed log.debug",
regex: /\[(?:debug|dbug|dbg|de|d)\]/,
caseInsensitive: true
}, {
token: "markup.changed log.debug",
regex: /(?<=^[\s\d\p]*)\bD\b/
}, {
token: "markup.inserted log.info",
regex: /\b(?:HINT|INFO|INFORMATION|Info|NOTICE|II)\b|\b(?:info|information)\:/,
caseInsensitive: true
}, {
token: "markup.inserted log.info",
regex: /\[(?:information|info|inf|in|i)\]/,
caseInsensitive: true
}, {
token: "markup.inserted log.info",
regex: /(?<=^[\s\d\p]*)\bI\b/
}, {
token: "markup.deleted log.warning",
regex: /\b(?:WARNING|WARN|Warn|WW)\b|\bwarning\:/,
caseInsensitive: true
}, {
token: "markup.deleted log.warning",
regex: /\[(?:warning|warn|wrn|wn|w)\]/,
caseInsensitive: true
}, {
token: "markup.deleted log.warning",
regex: /(?<=^[\s\d\p]*)\bW\b/
}, {
token: "string.regexp, strong log.error",
regex: /\b(?:ALERT|CRITICAL|EMERGENCY|ERROR|FAILURE|FAIL|Fatal|FATAL|Error|EE)\b|\berror\:/,
caseInsensitive: true
}, {
token: "string.regexp, strong log.error",
regex: /\[(?:error|eror|err|er|e|fatal|fatl|ftl|fa|f)\]/,
caseInsensitive: true
}, {
token: "string.regexp, strong log.error",
regex: /(?<=^[\s\d\p]*)\bE\b/
}, {
token: "comment log.date",
regex: /\b\d{4}-\d{2}-\d{2}(?:T|\b)/
}, {
token: "comment log.date",
regex: /(?<=(?:^|\s))\d{2}[^\w\s]\d{2}[^\w\s]\d{4}\b/
}, {
token: "comment log.date",
regex: /\d{1,2}:\d{2}(?::\d{2}(?:[.,]\d{1,})?)?(?:Z| ?[+-]\d{1,2}:\d{2})?\b/
}, {
token: "constant.language",
regex: /\b(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{10}|[0-9a-fA-F]{7})\b/
}, {
token: "constant.language log.constant",
regex: /\b[0-9a-fA-F]{8}[-]?(?:[0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\b/
}, {
token: "constant.language log.constant",
regex: /\b(?:[0-9a-fA-F]{2,}[:-])+[0-9a-fA-F]{2,}\b/
}, {
token: "constant.language log.constant",
regex: /\b(?:[0-9]+|true|false|null)\b/
}, {
token: "string log.string",
regex: /"[^"]*"/
}, {
token: "string log.string",
regex: /(?<![\w])'[^']*'/
}, {
token: "string.regexp, emphasis log.exceptiontype",
regex: /\b[a-zA-Z.]*Exception\b/
}, {
token: "string.key, emphasis log.exception",
regex: /^[\t ]*at/,
push: [{
token: "string.key, emphasis log.exception",
regex: /$/,
next: "pop"
}, {
defaultToken: "string.key, emphasis log.exception"
}]
}, {
token: "constant.language log.constant",
regex: /\b[a-z]+:\/\/\S+\b\/?/
}, {
token: "constant.language log.constant",
regex: /(?<![\w\/\\])(?:[\w-]+\.)+(?:[\w-])+(?![\w\/\\])/
}]
}

this.normalizeRules();
};

LogHighlightRules.metaData = {
scopeName: "text.log",
fileTypes: ["log"],
name: "Log file"
}


oop.inherits(LogHighlightRules, TextHighlightRules);

exports.LogHighlightRules = LogHighlightRules;
});
2 changes: 1 addition & 1 deletion tool/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.parsePlist = function(xmlOrJSON, callback) {
} else {
try {
xmlOrJSON = xmlOrJSON.replace(
/("(?:\\.|[^"])*")|(?:,\s*)+([\]\}])|(\w+)\s*:|([\]\}]\s*[\[\{])|(\/\/.*|\/\*(?:[^\*]|\*(?=[^\/]))*?\*\/)/g,
/("(?:\\.|[^"\\])*")|(?:,\s*)+([\]\}])|(\w+)\s*:|([\]\}]\s*[\[\{])|(\/\/.*|\/\*(?:[^\*]|\*(?=[^\/]))*?\*\/)/g,
function(_, str, extraComma, noQuote, missingComma, comment) {
if (comment)
return "";
Expand Down
2 changes: 1 addition & 1 deletion tool/templates/mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ oop.inherits(Mode, TextMode);
// this.lineCommentStart = "%lineCommentStart%";
// this.blockComment = {start: "%blockCommentStart%", end: "%blockCommentEnd%"};
// Extra logic goes here.
this.$id = "ace/mode/%languageHighlightFilename%"
this.$id = "ace/mode/%languageHighlightFilename%";
}).call(Mode.prototype);

exports.Mode = Mode;
Expand Down