mirror of
https://github.com/ij-plugins/ijp-imagej-launcher.git
synced 2024-11-13 16:29:01 -08:00
Make logger immutable
This commit is contained in:
parent
b4cac81a72
commit
30d41e3a40
2 changed files with 5 additions and 9 deletions
|
|
@ -7,17 +7,13 @@ package ij_plugins.imagej_launcher
|
|||
|
||||
import ij_plugins.imagej_launcher.Logger.Level
|
||||
|
||||
class Logger:
|
||||
|
||||
var level: Level = Level.Info
|
||||
|
||||
class Logger(val level: Level = Level.Info):
|
||||
def debug(msg: String): Unit = pprint(Level.Debug, msg)
|
||||
def info(msg: String): Unit = pprint(Level.Info, msg)
|
||||
def error(msg: String): Unit = pprint(Level.Error, msg)
|
||||
|
||||
private def pprint(l: Level, message: String): Unit =
|
||||
if l.level <= level.level then println(s"${l.name}: $message")
|
||||
|
||||
def error(msg: String): Unit = pprint(Level.Error, msg)
|
||||
if l.level <= level.level then println(f"${l.name}%-5s: $message")
|
||||
|
||||
object Logger:
|
||||
enum Level(val level: Int, val name: String):
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import scopt.{DefaultOEffectSetup, OParser}
|
|||
import java.io.File
|
||||
|
||||
object Main:
|
||||
private val logger = new Logger()
|
||||
private var logger = new Logger()
|
||||
private val AppName = "ijp-imagej-launcher"
|
||||
// private val AppVersion = s"${Version.version} [${Version.buildTimeStr}]"
|
||||
private val AppVersion = s"0.1.0"
|
||||
|
|
@ -71,7 +71,7 @@ object Main:
|
|||
OParser.parse(parser1, args, Config())
|
||||
end parseCommandLine
|
||||
|
||||
private def setupLogger(logLevel: Logger.Level): Unit = logger.level = logLevel
|
||||
private def setupLogger(logLevel: Logger.Level): Unit = logger = new Logger(logLevel)
|
||||
|
||||
private def runLauncher(config: Config): Unit = new Launcher(logger).run(config)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue