mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-14 07:55:07 +00:00
Improve server logging and manually load logback
This commit is contained in:
parent
8b14015582
commit
98b87e1e13
3 changed files with 58 additions and 4 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
|
# Project crap
|
||||||
target
|
target
|
||||||
*.class
|
*.class
|
||||||
.idea/
|
.idea/
|
||||||
|
|
@ -7,8 +8,12 @@ out/
|
||||||
*.iws
|
*.iws
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
# Random
|
||||||
*.swp
|
*.swp
|
||||||
/*.csv
|
/*.csv
|
||||||
|
|
||||||
|
# Binary files
|
||||||
*.so
|
*.so
|
||||||
*.dll
|
*.dll
|
||||||
*.exe
|
*.exe
|
||||||
|
|
|
||||||
27
logback.xml
Normal file
27
logback.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- encoders are assigned the type
|
||||||
|
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default
|
||||||
|
http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout
|
||||||
|
-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>[%highlight(%5level)] %logger{35} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
|
<file>pslogin-debug.log</file>
|
||||||
|
<encoder>
|
||||||
|
<!--<pattern>%date{ISO8601} %highlight(%-5level) [%thread MDC{%X}] %logger{35} - %msg%n</pattern>-->
|
||||||
|
<pattern>%date{ISO8601} %-5level %X %logger{35} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<logger name="debug-logger" level="DEBUG">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</logger>
|
||||||
|
</configuration>
|
||||||
|
|
@ -3,6 +3,8 @@ import java.net.InetAddress
|
||||||
|
|
||||||
import akka.actor.{ActorSystem, Props}
|
import akka.actor.{ActorSystem, Props}
|
||||||
import ch.qos.logback.classic.LoggerContext
|
import ch.qos.logback.classic.LoggerContext
|
||||||
|
import ch.qos.logback.classic.joran.JoranConfigurator
|
||||||
|
import ch.qos.logback.core.joran.spi.JoranException
|
||||||
import ch.qos.logback.core.status._
|
import ch.qos.logback.core.status._
|
||||||
import ch.qos.logback.core.util.StatusPrinter
|
import ch.qos.logback.core.util.StatusPrinter
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
|
@ -24,6 +26,7 @@ object PsLogin {
|
||||||
println(ansi().fgBright(MAGENTA).a(""" / ___/\ \/ _// _ \/ __/ -_) |/ / -_) __/"""))
|
println(ansi().fgBright(MAGENTA).a(""" / ___/\ \/ _// _ \/ __/ -_) |/ / -_) __/"""))
|
||||||
println(ansi().fgBright(RED).a("""/_/ /___/_/ \___/_/ \__/|___/\__/_/""").reset())
|
println(ansi().fgBright(RED).a("""/_/ /___/_/ \___/_/ \__/|___/\__/_/""").reset())
|
||||||
println(""" Login Server - PSForever Project""")
|
println(""" Login Server - PSForever Project""")
|
||||||
|
println(""" http://psforever.net""")
|
||||||
println
|
println
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,17 +60,36 @@ object PsLogin {
|
||||||
statusUtil.getHighestLevel(0) >= Status.WARN
|
statusUtil.getHighestLevel(0) >= Status.WARN
|
||||||
}
|
}
|
||||||
|
|
||||||
def main(args : Array[String]) : Unit = {
|
/** Loads the logging configuration and starts logging */
|
||||||
banner()
|
def initializeLogging(logfile : String) : Unit = {
|
||||||
println(systemInformation)
|
|
||||||
|
|
||||||
// assume SLF4J is bound to logback in the current environment
|
// assume SLF4J is bound to logback in the current environment
|
||||||
val lc = slf4j.LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
|
val lc = slf4j.LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
|
||||||
|
|
||||||
|
try {
|
||||||
|
val configurator = new JoranConfigurator()
|
||||||
|
configurator.setContext(lc)
|
||||||
|
|
||||||
|
// reset any loaded settings
|
||||||
|
lc.reset()
|
||||||
|
configurator.doConfigure(logfile)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
case je : JoranException => ;
|
||||||
|
}
|
||||||
|
|
||||||
if(loggerHasErrors(lc)) {
|
if(loggerHasErrors(lc)) {
|
||||||
|
println("Loading log settings failed")
|
||||||
StatusPrinter.printInCaseOfErrorsOrWarnings(lc)
|
StatusPrinter.printInCaseOfErrorsOrWarnings(lc)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args : Array[String]) : Unit = {
|
||||||
|
// Early start up
|
||||||
|
banner()
|
||||||
|
println(systemInformation)
|
||||||
|
|
||||||
|
initializeLogging("logback.xml")
|
||||||
|
|
||||||
/** Initialize the PSCrypto native library
|
/** Initialize the PSCrypto native library
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue