Skip to content

Instantly share code, notes, and snippets.

@pflammertsma
Last active October 15, 2017 13:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pflammertsma/8523210 to your computer and use it in GitHub Desktop.
Save pflammertsma/8523210 to your computer and use it in GitHub Desktop.
Gedit highlighter file for gedit
<?xml version="1.0" encoding="UTF-8"?>
<language id="logcat" _name="logcat" version="2.0" _section="Others">
<metadata>
<property name="mimetypes">text/x-logcat</property>
<property name="globs">*.logcat</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="verbose" _name="Verbose" map-to="def:identifier"/>
<style id="debug" _name="Debug" map-to="def:preprocessor"/>
<style id="info" _name="Info" map-to="def:type"/>
<style id="warning" _name="Warning" map-to="def:constant"/>
<style id="error" _name="Error" map-to="def:keyword"/>
<style id="fatal" _name="Fatal" map-to="def:error"/>
<style id="others" _name="Others" map-to="def:comment"/>
</styles>
<definitions>
<context id="logcat">
<include>
<context id="comment1" style-ref="comment">
<start>^---------</start>
<end>$</end>
</context>
<context id="comment2" style-ref="comment">
<start>^#</start>
<end>$</end>
</context>
<context id="thread" style-ref="others">
<start>[ ]{2,}[0-9]+[ ]{2,}[0-9]+</start>
<end> </end>
</context>
<context id="datetime" style-ref="comment">
<start>^[0-9]{2}-[0-9]{2} [0-9]</start>
<end> </end>
</context>
<context id="verbose" style-ref="verbose">
<start>( V |V/|V\()</start>
<end>$</end>
</context>
<context id="debug" style-ref="debug">
<start>( D |D/|D\()</start>
<end>$</end>
</context>
<context id="info" style-ref="info">
<start>( I |I/|I\()</start>
<end>$</end>
</context>
<context id="warning" style-ref="warning">
<start>( W |W/|W\()</start>
<end>$</end>
</context>
<context id="error" style-ref="error">
<start>( E |E/|E\()</start>
<end>$</end>
</context>
<context id="fatal" style-ref="fatal">
<start>( F |F/|F\()</start>
<end>$</end>
</context>
</include>
</context>
</definitions>
</language>
@writtmeyer
Copy link

There is one comment context too many. Using the same id twice within the same hierarchy level is what causes the trouble here.

@writtmeyer
Copy link

Actually I prefer this in the "start" element: (.*\ W\ |W/). That way it works in normal mode as well as with verbose mode ("-v threadtime"). The latter is my preferred mode.

@pflammertsma
Copy link
Author

Thanks Wolfram, I had overlooked the -v flags. I added threadtime, time and process support. Unfortunately the regular expression matching of gedit isn't extremely flexible, so I'm not sure to which extent I could support the other flags, but I haven't looked into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment