I would like to setup a new language definition for log files with a certain format. I've been scouring the interwebs for a tutorial that actually works, and I've yet to find one. I've tried creating sublime-syntax
files, AAAPackageDev
files (both JSON and YAML), plus one other syntax package that I can't remember the name of -- none of them seem to work, with some of them leaving out important details, like where to save files, how to get the syntax definition to appear as an option (I suspect this is related to save location), or how the keyword.other.joelog
scope relates to the keyword.other
theme color (do you just drop the last bit? does the last bit have to match the scope set out in the header?). It's been very frustrating.
At its simplest, I'd like to take the following file and highlight it:
2015-11-25 14:35:11 [LOG] Blah Blah Blah
2015-11-25 14:35:11 [LOG] some log statement
2015-11-25 14:35:11 [LOG] some other log statement
2015-11-25 14:35:11 [DEBUG] some embedded filename: [[ /path/to/file ]]
2015-11-25 14:35:11 [INFO] .............. blah blah ..............
2015-11-25 14:35:11 [DEBUG] <<PASS>> Directory not found: [[ /some/dir/name ]]
2015-11-25 14:35:11 [ERROR] <<FAIL>> Directory found: [[ /some/other/dir/name ]]
2015-11-25 14:35:11 [WARNING] some strange condition occurred
Ultimately I'd like syntax definitions similar to the following:
- LOG lines should be "normal" text
- DEBUG lines should be treated entirely as comments
- ERROR lines should be treated as something else (e.g. a variable)
- INFO lines as normal except the word INFO should be highlighted as something (e.g. a keyword)
- WARNING similar to either ERROR or INFO
- have embedded strings in the format of
[[ some string ]]
highlighted as a string, irrespective of the type of line it's on - have
<<PASS>>
and<<FAIL>>
highlighted with different colors, irrespective of the type of line they're on
I'd be happy getting any of this to work when manually selecting the mode, and especially happy if I could have the mode selected based on the full filename (it would be selected based on a prefix, rather than just a suffix, e.g. joelog-20151126-110719.log keying off of both the 'joelog' prefix and the 'log' suffix).
Is this possible to do? I can write this in JSON, YAML, XML, Martian -- any language or style definition would be fine, if only I knew the rules.
Edit: Sorry, I meant to include the pages I've tried to follow:
- http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html
- http://www.sublimetext.com/docs/3/syntax.html
- https://github.com/SublimeText/AAAPackageDev
- https://packagecontrol.io/packages/SyntaxHighlightTools
With sublime-syntx
files I couldn't figure out how to get it to show up as an option. With AAAPackageDev
files, I could get my new syntax definition to show up, but it never highlighted anything, even when doing nothing more than following the tutorial (abandoning all of my own desires, just trying to get something to highlight in any fashion).
Thanks!