30 Temmuz 2012 Pazartesi

Highlighting log files in Notepad++



Popular programmer's editor  Notepad++ provides syntax highlighting for several programming and scripting languages. Because, I don't like reading code as plain text, this is very nice feature for a programmer like me. But better one is that Npp makes extendable this feature allowing you to create custom syntax highlighting:
User-defined language (UDL).


To take advantage of the UDL, open User-Defined Dialogue... under View menu:

A window like below one will pop up:

Now, you can play with the toy or import an existing UDL file (which is an XML file). My custom UDL for LogFiles is below. Save as LogFile.xml (or dowload directly):

<NotepadPlus>
    <UserLang name="LogFile" ext="log">
        <Settings>
            <Global caseIgnored="yes" />
            <TreatAsSymbol comment="no" commentLine="no" />
            <Prefix words1="no" words2="no" words3="no" words4="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Delimiters">[(0])0</Keywords>
            <Keywords name="Folder+"/>
            <Keywords name="Folder-"/>
            <Keywords name="Operators">&apos; - ! &quot; # $ % &amp; ( ) * , . / : ; ? @ [ \ ] ^ _ ` { | } ~ + &lt; = &gt;</Keywords>
            <Keywords name="Comment">1 2 0</Keywords>
            <Keywords name="Words1">ERROR</Keywords>
            <Keywords name="Words2">WARN WARNING</Keywords>
            <Keywords name="Words3">DEBUG</Keywords>
            <Keywords name="Words4">INFO</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" styleID="11" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="KEYWORD1" styleID="5" fgColor="FFFFFF" 
                        bgColor="FF0000" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD2" styleID="6" fgColor="FFFFFF" 
                        bgColor="FF8000" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD3" styleID="7" fgColor="FFFFFF" 
                        bgColor="FF80FF" fontName="" fontStyle="1" />
            <WordsStyle name="KEYWORD4" styleID="8" fgColor="FFFFFF" 
                        bgColor="0080FF" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT" styleID="1" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="COMMENT LINE" styleID="2" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="NUMBER" styleID="4" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
            <WordsStyle name="OPERATOR" styleID="10" fgColor="FF0080" 
                        bgColor="FFFFFF" fontName="" fontStyle="1" />
            <WordsStyle name="DELIMINER1" styleID="14" fgColor="000000" 
                        bgColor="FFFFBF" fontName="" fontStyle="1" />
            <WordsStyle name="DELIMINER2" styleID="15" fgColor="800000" 
                        bgColor="FFFFFF" fontName="" fontStyle="2" />
            <WordsStyle name="DELIMINER3" styleID="16" fgColor="000000" 
                        bgColor="FFFFFF" fontName="" fontStyle="0" />
        </Styles>
    </UserLang>
</NotepadPlus>



Press Import... button and select LogFile.xml you just saved:



OK. Whenever you want to highlight a file according to LogFile UDL rules, you can select it under Language menu:


But, this is impractical. You want to see log files highlighted everytime you open a file with .log extension, don't you? So, you should associate log extension with LogFile UDL. Just write the extension to the box labeled as Ext. Note that you can write multiple extension separating them with spaces:


You will end up a log file like below:

Nice, isn't it?

Hiç yorum yok:

WSO2 ESB + ClientAccesPolicy.xml + CrossDomain.xml

ClientAccesPolicy.xml and CrossDomain.xml files have to be found at root of your services Silverlight and Flex clients to be able to acce...