mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Improve server logging and manually load logback
This commit is contained in:
parent
8b14015582
commit
98b87e1e13
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
# Project crap
|
||||
target
|
||||
*.class
|
||||
.idea/
|
||||
|
|
@ -7,8 +8,12 @@ out/
|
|||
*.iws
|
||||
*.ipr
|
||||
*.iml
|
||||
|
||||
# Random
|
||||
*.swp
|
||||
/*.csv
|
||||
|
||||
# Binary files
|
||||
*.so
|
||||
*.dll
|
||||
*.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 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.util.StatusPrinter
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
|
@ -24,6 +26,7 @@ object PsLogin {
|
|||
println(ansi().fgBright(MAGENTA).a(""" / ___/\ \/ _// _ \/ __/ -_) |/ / -_) __/"""))
|
||||
println(ansi().fgBright(RED).a("""/_/ /___/_/ \___/_/ \__/|___/\__/_/""").reset())
|
||||
println(""" Login Server - PSForever Project""")
|
||||
println(""" http://psforever.net""")
|
||||
println
|
||||
}
|
||||
|
||||
|
|
@ -57,17 +60,36 @@ object PsLogin {
|
|||
statusUtil.getHighestLevel(0) >= Status.WARN
|
||||
}
|
||||
|
||||
def main(args : Array[String]) : Unit = {
|
||||
banner()
|
||||
println(systemInformation)
|
||||
|
||||
/** Loads the logging configuration and starts logging */
|
||||
def initializeLogging(logfile : String) : Unit = {
|
||||
// assume SLF4J is bound to logback in the current environment
|
||||
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)) {
|
||||
println("Loading log settings failed")
|
||||
StatusPrinter.printInCaseOfErrorsOrWarnings(lc)
|
||||
sys.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
def main(args : Array[String]) : Unit = {
|
||||
// Early start up
|
||||
banner()
|
||||
println(systemInformation)
|
||||
|
||||
initializeLogging("logback.xml")
|
||||
|
||||
/** Initialize the PSCrypto native library
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue