logging - Html tags in Jenkins log -


all!

for 1 of our projects using jenkins continuous integration system. build process pretty heavy , produce lot of different logs. make logs easier read decided create jenkins plugin reformat logs , makes them more readable. purpose created extension consolelogfilter. 1 overridden method there looks this:

public outputstream decoratelogger(abstractbuild abstractbuild, outputstream outputstream) throws ioexception, interruptedexception {     filteroutputstream filter = new filteroutputstream(outputstream) {            private string currentlogmessage = "";            @override            public void write( int data ) throws ioexception {                switch (data) {                    case '\n':                        if (currentlogmessage.startswith("+")) {                            currentlogmessage = "<span style='color: darkgray; font-size: 10pt'>" + currentlogmessage + "</span>";                        }                        currentlogmessage += character.tostring ((char) data);                        out.write( currentlogmessage.getbytes() );                        system.out.println(currentlogmessage);                        currentlogmessage = "";                        break;                    default:                        currentlogmessage += character.tostring ((char) data);                        break;                }            }        };      return filter; } 

the problem appeared tricky. decorator doing it's job pretty , in jenkins log see messages wrapped html-span correctly (result of system.out.println(...)). looks this:

<span style='color: darkgray; font-size: 10pt'>+ log content</span> <span style='color: darkgray; font-size: 10pt'>+ log content</span> <span style='color: darkgray; font-size: 10pt'>+ log content</span> 

but when comes browser appears opening tag symbols < replaced &lt; , browser can't parse formatting correctly

&lt;span style='color: darkgray; font-size: 10pt'>+ log content&lt;/span> &lt;span style='color: darkgray; font-size: 10pt'>+ log content&lt;/span> &lt;span style='color: darkgray; font-size: 10pt'>+ log content&lt;/span> 

do saw problem? there way fix it?


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -