Skip to content

Commit

Permalink
feat: impl log grammar
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Bassett <[email protected]>
  • Loading branch information
cadriel committed Jun 16, 2021
1 parent 180b991 commit 86bff7c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 119 deletions.
4 changes: 2 additions & 2 deletions src/components/widgets/filesystem/FileEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export default class FileEditor extends Vue {
const grammars = new Map()
grammars.set('gcode', 'source.gcode')
grammars.set('klipper-config', 'source.klipper-config')
// grammars.set('log', 'text.log')
grammars.set('log', 'text.log')
// ... and our languages
monaco.languages.register({ id: 'gcode', extensions: ['gcode', 'g', 'gc', 'gco', 'ufp', 'nc'] })
monaco.languages.register({ id: 'klipper-config', extensions: ['cfg', 'conf'] })
// monaco.languages.register({ id: 'log', extensions: ['log'] })
monaco.languages.register({ id: 'log', extensions: ['log'] })
// Define how commenting works.
monaco.languages.setLanguageConfiguration('gcode', {
Expand Down
182 changes: 65 additions & 117 deletions src/monaco/language/log.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,119 +1,67 @@
{
"name": "Log file",
"scopeName": "text.log",
"patterns": [
{
"match": "\\b(Trace)\\b:",
"name": "comment log.verbose"
},
{
"match": "(?i)\\[(verbose|verb|vrb|vb|v)\\]",
"name": "comment log.verbose"
},
{
"match": "(?<=^[\\s\\d\\p]*)\\bV\\b",
"name": "comment log.verbose"
},
{
"match": "\\b(DEBUG|Debug)\\b|(?i)\\b(debug)\\:",
"name": "markup.changed log.debug"
},
{
"match": "(?i)\\[(debug|dbug|dbg|de|d)\\]",
"name": "markup.changed log.debug"
},
{
"match": "(?<=^[\\s\\d\\p]*)\\bD\\b",
"name": "markup.changed log.debug"
},
{
"match": "\\b(HINT|INFO|INFORMATION|Info|NOTICE|II)\\b|(?i)\\b(info|information)\\:",
"name": "markup.inserted log.info"
},
{
"match": "(?i)\\[(information|info|inf|in|i)\\]",
"name": "markup.inserted log.info"
},
{
"match": "(?<=^[\\s\\d\\p]*)\\bI\\b",
"name": "markup.inserted log.info"
},
{
"match": "\\b(WARNING|WARN|Warn|WW)\\b|(?i)\\b(warning)\\:",
"name": "markup.deleted log.warning"
},
{
"match": "(?i)\\[(warning|warn|wrn|wn|w)\\]",
"name": "markup.deleted log.warning"
},
{
"match": "(?<=^[\\s\\d\\p]*)\\bW\\b",
"name": "markup.deleted log.warning"
},
{
"match": "\\b(ALERT|CRITICAL|EMERGENCY|ERROR|FAILURE|FAIL|Fatal|FATAL|Error|EE)\\b|(?i)\\b(error)\\:",
"name": "string.regexp, strong log.error"
},
{
"match": "(?i)\\[(error|eror|err|er|e|fatal|fatl|ftl|fa|f)\\]",
"name": "string.regexp, strong log.error"
},
{
"match": "(?<=^[\\s\\d\\p]*)\\bE\\b",
"name": "string.regexp, strong log.error"
},
{
"match": "\\b\\d{4}-\\d{2}-\\d{2}(T|\\b)",
"name": "comment log.date"
},
{
"match": "(?<=(^|\\s))\\d{2}[^\\w\\s]\\d{2}[^\\w\\s]\\d{4}\\b",
"name": "comment log.date"
},
{
"match": "\\d{1,2}:\\d{2}(:\\d{2}([.,]\\d{1,})?)?(Z| ?[+-]\\d{1,2}:\\d{2})?\\b",
"name": "comment log.date"
},
{
"match": "\\b([0-9a-fA-F]{40}|[0-9a-fA-F]{10}|[0-9a-fA-F]{7})\\b",
"name": "constant.language"
},
{
"match": "\\b[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}\\b",
"name": "constant.language log.constant"
},
{
"match": "\\b([0-9a-fA-F]{2,}[:-])+[0-9a-fA-F]{2,}+\\b",
"name": "constant.language log.constant"
},
{
"match": "\\b([0-9]+|true|false|null)\\b",
"name": "constant.language log.constant"
},
{
"match": "\"[^\"]*\"",
"name": "string log.string"
},
{
"match": "(?<![\\w])'[^']*'",
"name": "string log.string"
},
{
"match": "\\b([a-zA-Z.]*Exception)\\b",
"name": "string.regexp, emphasis log.exceptiontype"
},
{
"begin": "^[\\t ]*at",
"end": "$",
"name": "string.key, emphasis log.exception"
},
{
"match": "\\b[a-z]+://\\S+\\b/?",
"name": "constant.language log.constant"
},
{
"match": "(?<![\\w/\\\\])([\\w-]+\\.)+([\\w-])+(?![\\w/\\\\])",
"name": "constant.language log.constant"
}
]
}
"fileTypes": ["log"],
"name": "Log file",
"patterns": [{
"match": "\\b(DEBUG|Debug|Trace)\\b|(?i)\\b(debug)\\:",
"name": "markup.changed"
}, {
"match": "(?i)\\[(debug|dbug|dbg|de|d)\\]",
"name": "markup.changed"
}, {
"match": "\\b(HINT|INFO|INFORMATION|Info|NOTICE)\\b|(?i)\\b(info|information)\\:",
"name": "markup.inserted"
}, {
"match": "(?i)\\[(information|info|inf|in|i)\\]",
"name": "markup.inserted"
}, {
"match": "\\b(WARNING|WARN|Warn)\\b|(?i)\\b(warning)\\:",
"name": "markup.deleted"
}, {
"match": "(?i)\\[(warning|warn|wrn|wn|w)\\]",
"name": "markup.deleted"
}, {
"match": "\\b(ALERT|CRITICAL|EMERGENCY|ERROR|FAILURE|FAIL|Fatal|Error)\\b|(?i)\\b(error)\\:",
"name": "string.regexp"
}, {
"match": "(?i)\\[(error|eror|err|er|e|fatal|fatl|ftl|fa|f)\\]",
"name": "string.regexp"
}, {
"match": "\\b\\d{4}-\\d{2}-\\d{2}(T|\\b)",
"name": "comment"
}, {
"match": "\\b\\d{2}[^\\w\\s]\\d{2}[^\\w\\s]\\d{4}\\b",
"name": "comment"
}, {
"match": "\\d{2}:\\d{2}(:\\d{2}([.,]\\d{3,})?)?(Z| ?[+-]\\d{2}:\\d{2})?\\b",
"name": "comment"
}, {
"match": "\\b([0-9a-fA-F]{40}|[0-9a-fA-F]{10}|[0-9a-fA-F]{7})\\b",
"name": "constant.language"
}, {
"match": "[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}",
"name": "constant.language"
}, {
"match": "\\b([0-9]+|true|false|null)\\b",
"name": "constant.language"
}, {
"match": "\"[^\"]*\"",
"name": "string"
}, {
"match": "(^|[^\\w])'[^']*'",
"name": "string"
}, {
"match": "\\b([a-zA-Z.]*Exception)\\b",
"name": "string.regexp, emphasis"
}, {
"begin": "^[\\t ]*at",
"end": "$",
"name": "string.key, emphasis"
}, {
"match": "\\b(http|https|ftp|file):\/\/\\S+\\b\/?",
"name": "constant.language"
}, {
"match": "\\b([\\w-]+\\.)+([\\w-])+\\b",
"name": "constant.language"
}]
}

0 comments on commit 86bff7c

Please sign in to comment.