From 243a814a4eca7dfac2cfe5b8689ba0a03a28f62e Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 26 May 2021 15:03:20 +0400 Subject: [PATCH 1/2] add log_file highlighter --- demo/kitchen-sink/docs/log.log | 15 +++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/log.js | 54 ++++++++++ lib/ace/mode/log_highlight_rules.js | 160 ++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 demo/kitchen-sink/docs/log.log create mode 100644 lib/ace/mode/log.js create mode 100644 lib/ace/mode/log_highlight_rules.js diff --git a/demo/kitchen-sink/docs/log.log b/demo/kitchen-sink/docs/log.log new file mode 100644 index 00000000000..9614bd2ed69 --- /dev/null +++ b/demo/kitchen-sink/docs/log.log @@ -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 diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index e9fa1fb3a5c..d8b9a796b2f 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -124,6 +124,7 @@ var supportedModes = { Liquid: ["liquid"], Lisp: ["lisp"], LiveScript: ["ls"], + Log: ["log"], LogiQL: ["logic|lql"], LSL: ["lsl"], Lua: ["lua"], diff --git a/lib/ace/mode/log.js b/lib/ace/mode/log.js new file mode 100644 index 00000000000..b4083250e00 --- /dev/null +++ b/lib/ace/mode/log.js @@ -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; +}); \ No newline at end of file diff --git a/lib/ace/mode/log_highlight_rules.js b/lib/ace/mode/log_highlight_rules.js new file mode 100644 index 00000000000..0c1d86eef67 --- /dev/null +++ b/lib/ace/mode/log_highlight_rules.js @@ -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: /(? Date: Wed, 26 May 2021 15:03:20 +0400 Subject: [PATCH 2/2] fix tmlanguage converter --- lib/ace/mode/log.js | 2 +- tool/lib.js | 2 +- tool/templates/mode.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/mode/log.js b/lib/ace/mode/log.js index b4083250e00..e5f902283db 100644 --- a/lib/ace/mode/log.js +++ b/lib/ace/mode/log.js @@ -47,7 +47,7 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { - this.$id = "ace/mode/log" + this.$id = "ace/mode/log"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/tool/lib.js b/tool/lib.js index 3d57b6e005e..fd2df7abdad 100644 --- a/tool/lib.js +++ b/tool/lib.js @@ -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 ""; diff --git a/tool/templates/mode.js b/tool/templates/mode.js index 1cdabf15743..ae3001537bb 100644 --- a/tool/templates/mode.js +++ b/tool/templates/mode.js @@ -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;