Skip to content

Commit

Permalink
Merge pull request #29 from almeiduh/xml_logging
Browse files Browse the repository at this point in the history
Added ability to view logs with XML tags
  • Loading branch information
jdrews committed Mar 14, 2018
2 parents 90d43f7 + 61933f5 commit 72988ae
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
10 changes: 4 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "logstation"

version := "0.3.8"
version := "0.3.9"

scalaVersion := "2.10.4"

Expand All @@ -18,8 +18,6 @@ assemblyMergeStrategy in assembly := {
oldStrategy(x)
}

seq(webSettings :_*)

resolvers ++= Seq(
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
)
Expand All @@ -37,10 +35,10 @@ libraryDependencies ++= {
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftmodules" %% "lift-jquery-module_2.6" % "2.9",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "compile,container,test",
"org.eclipse.jetty" % "jetty-plus" % "8.1.7.v20120910" % "container,test", // For Jetty Config
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "compile,test",
"org.eclipse.jetty" % "jetty-plus" % "8.1.7.v20120910" % "test", // For Jetty Config
"org.eclipse.jetty" % "jetty-servlets" % "8.1.7.v20120910",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,test" artifacts Artifact("javax.servlet", "jar", "jar"),
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "test" artifacts Artifact("javax.servlet", "jar", "jar"),
"ch.qos.logback" % "logback-classic" % "1.0.6",
"org.specs2" %% "specs2" % "2.3.12" % "test"
)
Expand Down
2 changes: 1 addition & 1 deletion project/assembly.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logLevel := Level.Warn

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.7.0")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.2")
15 changes: 14 additions & 1 deletion src/main/resources/webapp/js/LogStationScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function addOrAppendLogMessage(logFile, logMessage) {
if (logDiv.length) {
// log file already exists, append message
console.log("appending to " + logId + " the message " + logMessage);
logDiv.append("<div class=logMessage>" + logMessage + "<br/></div>")
logDiv.append("<div class=logMessage>" + escapeXMLHtml(logMessage) + "<br/></div>")
} else {
// log file doesn't exist yet. add it with this message
console.log("adding new logFile " + logId);
Expand Down Expand Up @@ -261,3 +261,16 @@ $( "#pause-button" ).click(function() {
$( "#regex-button" ).click(function() {
updateRegex()
});

function escapeXMLHtml(unsafe) {
if(unsafe.startsWith("<?xml")) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
} else {
return unsafe;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LogStationColorizer extends Actor with ActorLogging {
if (syntax._2.findFirstIn(lm.logMessage).isDefined) {
// log.debug(s"got a match! ${syntax._1}")
// wrap log message in new colors
msg = s"<span style='color:${syntax._1}'>${lm.logMessage}</span>"
msg = s"<span style='color:${syntax._1}'>${xml.Utility.escape(lm.logMessage)}</span>"
loop.break
}
)
Expand Down

0 comments on commit 72988ae

Please sign in to comment.