Bumped up logback version, added MDC to boot

This commit is contained in:
Petar Bozin 2017-04-19 14:10:19 +02:00
parent b734459a0e
commit 9147a77046
3 changed files with 17 additions and 8 deletions

View File

@ -78,7 +78,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>

View File

@ -38,16 +38,13 @@ import common._
import http._
import sitemap._
import Loc._
import mapper._
import Helpers._
import json.JsonDSL._
import net.liftmodules.widgets.tablesorter.TableSorter
import java.io.FileInputStream
import java.io.File
import code.lib.{OAuthClient, ObpGet, ObpJson, ObpAPI}
import ObpJson._
import code.snippet._
import code.util.MyExceptionLogger
import code.lib.{OAuthClient, ObpJson}
import code.util.{Helper, MyExceptionLogger}
/**
* A class that's instantiated early and run. It allows the application
@ -56,6 +53,9 @@ import code.util.MyExceptionLogger
class Boot extends Loggable{
def boot {
MDC.clear()
MDC.put( ("host", Helper.getHostname()) )
val runningMode = Props.mode match {
case Props.RunModes.Production => "Production mode"
case Props.RunModes.Staging => "Staging mode"

View File

@ -3,6 +3,7 @@ package code.util
import code.lib.ObpAPI._
import code.lib.ObpJson.AccountJson
import net.liftweb.common.Full
import net.liftweb.util.Props
object Helper {
@ -43,7 +44,15 @@ Returns a string which can be used for the title of the account
}
def getHostname(): String = {
Props.get("hostname", "") match {
case s: String if s.nonEmpty => s.split(":").lift(1) match {
case Some(s) => s.replaceAll("\\/", "").replaceAll("\\.", "-")
case None => "unknown"
}
case _ => "unknown"
}
}
}