chore: move logging in kotlin code to Log object
This commit is contained in:
parent
502026bb22
commit
5b79987dcf
|
@ -3,6 +3,7 @@ package io.gitlab.jfronny.inceptum.gtk
|
||||||
import io.gitlab.jfronny.commons.StringFormatter
|
import io.gitlab.jfronny.commons.StringFormatter
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.dialog.MicrosoftLoginDialog
|
import io.gitlab.jfronny.inceptum.gtk.window.dialog.MicrosoftLoginDialog
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.dialog.StringInputDialog
|
import io.gitlab.jfronny.inceptum.gtk.window.dialog.StringInputDialog
|
||||||
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv.EnvBackend
|
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv.EnvBackend
|
||||||
|
@ -16,7 +17,7 @@ object GtkEnvBackend : EnvBackend {
|
||||||
var dialogParent: Window? = null
|
var dialogParent: Window? = null
|
||||||
|
|
||||||
override fun showError(message: String, title: String) {
|
override fun showError(message: String, title: String) {
|
||||||
Utils.LOGGER.error(message)
|
Log.error(message)
|
||||||
simpleDialog(message, title, null, null)
|
simpleDialog(message, title, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +26,12 @@ object GtkEnvBackend : EnvBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showInfo(message: String, title: String) {
|
override fun showInfo(message: String, title: String) {
|
||||||
Utils.LOGGER.info(message)
|
Log.info(message)
|
||||||
simpleDialog(message, title, null, null)
|
simpleDialog(message, title, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showOkCancel(message: String, title: String, ok: Runnable, cancel: Runnable, defaultCancel: Boolean) {
|
override fun showOkCancel(message: String, title: String, ok: Runnable, cancel: Runnable, defaultCancel: Boolean) {
|
||||||
Utils.LOGGER.info(message)
|
Log.info(message)
|
||||||
simpleDialog(message, title, ok, cancel)
|
simpleDialog(message, title, ok, cancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ object GtkEnvBackend : EnvBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseType.DELETE_EVENT -> dialog.destroy()
|
ResponseType.DELETE_EVENT -> dialog.destroy()
|
||||||
else -> Utils.LOGGER.error("Unexpected response type: $responseId")
|
else -> Log.error("Unexpected response type: $responseId")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.gitlab.jfronny.inceptum.gtk
|
||||||
import io.gitlab.jfronny.inceptum.common.BuildMetadata
|
import io.gitlab.jfronny.inceptum.common.BuildMetadata
|
||||||
import io.gitlab.jfronny.inceptum.common.MetaHolder
|
import io.gitlab.jfronny.inceptum.common.MetaHolder
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.MainWindow
|
import io.gitlab.jfronny.inceptum.gtk.window.MainWindow
|
||||||
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv
|
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv
|
||||||
import io.gitlab.jfronny.inceptum.launcher.api.account.AccountManager
|
import io.gitlab.jfronny.inceptum.launcher.api.account.AccountManager
|
||||||
|
@ -19,8 +20,8 @@ object GtkMain {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
LauncherEnv.initialize(GtkEnvBackend)
|
LauncherEnv.initialize(GtkEnvBackend)
|
||||||
Utils.LOGGER.info("Launching Inceptum v" + BuildMetadata.VERSION)
|
Log.info("Launching Inceptum v" + BuildMetadata.VERSION)
|
||||||
Utils.LOGGER.info("Loading from " + MetaHolder.BASE_PATH)
|
Log.info("Loading from " + MetaHolder.BASE_PATH)
|
||||||
exitProcess(try {
|
exitProcess(try {
|
||||||
showGui(args)
|
showGui(args)
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.gitlab.jfronny.inceptum.common.MetaHolder
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.menu.MenuBuilder
|
import io.gitlab.jfronny.inceptum.gtk.menu.MenuBuilder
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.AboutWindow
|
import io.gitlab.jfronny.inceptum.gtk.window.AboutWindow
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.create.NewInstanceWindow
|
import io.gitlab.jfronny.inceptum.gtk.window.create.NewInstanceWindow
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.dialog.MicrosoftLoginDialog
|
import io.gitlab.jfronny.inceptum.gtk.window.dialog.MicrosoftLoginDialog
|
||||||
|
@ -155,7 +156,7 @@ object GtkMenubar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not generate launch menu", e)
|
Log.error("Could not generate launch menu", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ object GtkMenubar {
|
||||||
try {
|
try {
|
||||||
Steps.reDownload(instance, state)
|
Steps.reDownload(instance, state)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not fetch instance, trying to start anyways", e)
|
Log.error("Could not fetch instance, trying to start anyways", e)
|
||||||
}
|
}
|
||||||
if (state.isCancelled) return@show
|
if (state.isCancelled) return@show
|
||||||
state.updateStep("Starting Game")
|
state.updateStep("Starting Game")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package io.gitlab.jfronny.inceptum.gtk
|
package io.gitlab.jfronny.inceptum.gtk
|
||||||
|
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
private val SCHEDULED: Queue<Runnable> = ArrayDeque()
|
private val SCHEDULED: Queue<Runnable> = ArrayDeque()
|
||||||
|
@ -15,7 +15,7 @@ fun runScheduledTasks() {
|
||||||
try {
|
try {
|
||||||
r!!.run()
|
r!!.run()
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
Utils.LOGGER.error("Could not run scheduled task", t)
|
Log.error("Could not run scheduled task", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package io.gitlab.jfronny.inceptum.gtk.control.assistant
|
package io.gitlab.jfronny.inceptum.gtk.control.assistant
|
||||||
|
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import org.gnome.gtk.Application
|
import org.gnome.gtk.Application
|
||||||
import org.gnome.gtk.Assistant
|
import org.gnome.gtk.Assistant
|
||||||
import org.gnome.gtk.AssistantPageType
|
import org.gnome.gtk.AssistantPageType
|
||||||
|
@ -13,7 +14,7 @@ open class KAssistant(app: Application) : Assistant() {
|
||||||
onPrepare { next ->
|
onPrepare { next ->
|
||||||
val page = pages.firstOrNull { it.handle() == next.handle() }
|
val page = pages.firstOrNull { it.handle() == next.handle() }
|
||||||
if (page == null) {
|
if (page == null) {
|
||||||
Utils.LOGGER.error("Unknown page opened in assistant")
|
Log.error("Unknown page opened in assistant")
|
||||||
} else {
|
} else {
|
||||||
page.emitOpen()
|
page.emitOpen()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package io.gitlab.jfronny.inceptum.gtk.control.settings
|
package io.gitlab.jfronny.inceptum.gtk.control.settings
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import org.gnome.adw.HeaderBar
|
import org.gnome.adw.HeaderBar
|
||||||
import org.gnome.adw.ViewStack
|
import org.gnome.adw.ViewStack
|
||||||
import org.gnome.adw.ViewSwitcherBar
|
import org.gnome.adw.ViewSwitcherBar
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.gitlab.jfronny.inceptum.gtk.menu
|
||||||
import io.gitlab.jfronny.commons.throwable.ThrowingRunnable
|
import io.gitlab.jfronny.commons.throwable.ThrowingRunnable
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import org.gnome.gio.*
|
import org.gnome.gio.*
|
||||||
import org.gnome.glib.Variant
|
import org.gnome.glib.Variant
|
||||||
import org.gnome.glib.VariantType
|
import org.gnome.glib.VariantType
|
||||||
|
@ -51,7 +52,7 @@ class MenuBuilder private constructor(map: ActionMap, menu: Menu, prefix: String
|
||||||
try {
|
try {
|
||||||
onClick.run()
|
onClick.run()
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Utils.LOGGER.error("Could not execute action", e)
|
Log.error("Could not execute action", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val menuItem = MenuItem(label, groupName + internalName)
|
val menuItem = MenuItem(label, groupName + internalName)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package io.gitlab.jfronny.inceptum.gtk.util
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.commons.log.Logger
|
||||||
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
|
|
||||||
|
object Log : Logger by Utils.LOGGER
|
|
@ -35,12 +35,12 @@ object Memory {
|
||||||
return if (memTotal.isPresent()) {
|
return if (memTotal.isPresent()) {
|
||||||
parseDecimalMemorySizeToBinary(memTotal.get())
|
parseDecimalMemorySizeToBinary(memTotal.get())
|
||||||
} else {
|
} else {
|
||||||
Utils.LOGGER.error("Could not find total memory")
|
Log.error("Could not find total memory")
|
||||||
32 * GB
|
32 * GB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not get total memory", e)
|
Log.error("Could not get total memory", e)
|
||||||
return 32 * GB
|
return 32 * GB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ class MainWindow(app: Application) : ApplicationWindow(app) {
|
||||||
try {
|
try {
|
||||||
setupDirWatcher()
|
setupDirWatcher()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error(
|
Log.error(
|
||||||
"Could not set up watch service, live updates of the instance dir will be unavailable",
|
"Could not set up watch service, live updates of the instance dir will be unavailable",
|
||||||
e
|
e
|
||||||
)
|
)
|
||||||
|
@ -126,7 +126,7 @@ class MainWindow(app: Application) : ApplicationWindow(app) {
|
||||||
try {
|
try {
|
||||||
if (isw.poll()) generateWindowBody()
|
if (isw.poll()) generateWindowBody()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not run update task", e)
|
Log.error("Could not run update task", e)
|
||||||
}
|
}
|
||||||
GLib.SOURCE_CONTINUE
|
GLib.SOURCE_CONTINUE
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ class MainWindow(app: Application) : ApplicationWindow(app) {
|
||||||
stack.queueResize()
|
stack.queueResize()
|
||||||
stack.queueDraw()
|
stack.queueDraw()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not generate window body", e)
|
Log.error("Could not generate window body", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.gitlab.jfronny.inceptum.gtk.control.KEntry
|
||||||
import io.gitlab.jfronny.inceptum.gtk.control.assistant.KAssistant
|
import io.gitlab.jfronny.inceptum.gtk.control.assistant.KAssistant
|
||||||
import io.gitlab.jfronny.inceptum.gtk.schedule
|
import io.gitlab.jfronny.inceptum.gtk.schedule
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.kText
|
import io.gitlab.jfronny.inceptum.gtk.util.kText
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.toTypedArray
|
import io.gitlab.jfronny.inceptum.gtk.util.toTypedArray
|
||||||
import io.gitlab.jfronny.inceptum.gtk.window.dialog.ProcessStateWatcherDialog
|
import io.gitlab.jfronny.inceptum.gtk.window.dialog.ProcessStateWatcherDialog
|
||||||
|
@ -147,7 +148,7 @@ class NewInstanceWindow(app: Application) : KAssistant(app) {
|
||||||
try {
|
try {
|
||||||
JFiles.deleteRecursive(MetaHolder.INSTANCE_DIR.resolve(state.name))
|
JFiles.deleteRecursive(MetaHolder.INSTANCE_DIR.resolve(state.name))
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Utils.LOGGER.error("Could not delete instance dir", e)
|
Log.error("Could not delete instance dir", e)
|
||||||
}
|
}
|
||||||
return@Thread
|
return@Thread
|
||||||
}
|
}
|
||||||
|
@ -156,7 +157,7 @@ class NewInstanceWindow(app: Application) : KAssistant(app) {
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
pState.cancel()
|
pState.cancel()
|
||||||
Utils.LOGGER.error("Could not create instance")
|
Log.error("Could not create instance")
|
||||||
failureMessage = StringFormatter.toString(e)
|
failureMessage = StringFormatter.toString(e)
|
||||||
isFailure = true
|
isFailure = true
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.gitlab.jfronny.inceptum.gtk.window.dialog
|
||||||
|
|
||||||
import io.gitlab.jfronny.inceptum.common.Utils
|
import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAccount
|
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAccount
|
||||||
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAuthAPI
|
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAuthAPI
|
||||||
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAuthServer
|
import io.gitlab.jfronny.inceptum.launcher.api.account.MicrosoftAuthServer
|
||||||
|
@ -28,7 +29,7 @@ class MicrosoftLoginDialog(
|
||||||
try {
|
try {
|
||||||
server.start()
|
server.start()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Utils.LOGGER.error("Could not start mc login server", e)
|
Log.error("Could not start mc login server", e)
|
||||||
}
|
}
|
||||||
val finalize = Runnable {
|
val finalize = Runnable {
|
||||||
server.close()
|
server.close()
|
||||||
|
@ -46,7 +47,7 @@ class MicrosoftLoginDialog(
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Utils.LOGGER.error("Unexpected response type: $responseId")
|
else -> Log.error("Unexpected response type: $responseId")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val btn = Button.newWithLabel(I18n["auth.open-browser"])
|
val btn = Button.newWithLabel(I18n["auth.open-browser"])
|
||||||
|
@ -55,7 +56,7 @@ class MicrosoftLoginDialog(
|
||||||
try {
|
try {
|
||||||
Utils.openWebBrowser(URI(MicrosoftAuthAPI.MICROSOFT_LOGIN_URL))
|
Utils.openWebBrowser(URI(MicrosoftAuthAPI.MICROSOFT_LOGIN_URL))
|
||||||
} catch (e: URISyntaxException) {
|
} catch (e: URISyntaxException) {
|
||||||
Utils.LOGGER.error("Could not open browser", e)
|
Log.error("Could not open browser", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCloseRequest {
|
onCloseRequest {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.gitlab.jfronny.inceptum.common.Utils
|
||||||
import io.gitlab.jfronny.inceptum.gtk.GtkEnvBackend
|
import io.gitlab.jfronny.inceptum.gtk.GtkEnvBackend
|
||||||
import io.gitlab.jfronny.inceptum.gtk.schedule
|
import io.gitlab.jfronny.inceptum.gtk.schedule
|
||||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n
|
||||||
|
import io.gitlab.jfronny.inceptum.gtk.util.Log
|
||||||
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState
|
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState
|
||||||
import org.gnome.glib.GLib
|
import org.gnome.glib.GLib
|
||||||
import org.gnome.gtk.*
|
import org.gnome.gtk.*
|
||||||
|
@ -39,7 +40,7 @@ class ProcessStateWatcherDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseType.DELETE_EVENT -> destroy()
|
ResponseType.DELETE_EVENT -> destroy()
|
||||||
else -> Utils.LOGGER.error("Unexpected response type: $responseId")
|
else -> Log.error("Unexpected response type: $responseId")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCloseRequest {
|
onCloseRequest {
|
||||||
|
@ -65,7 +66,7 @@ class ProcessStateWatcherDialog(
|
||||||
executor.run()
|
executor.run()
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
state.cancel()
|
state.cancel()
|
||||||
Utils.LOGGER.error(errorMessage, e)
|
Log.error(errorMessage, e)
|
||||||
GtkEnvBackend.simpleDialog(
|
GtkEnvBackend.simpleDialog(
|
||||||
parent,
|
parent,
|
||||||
StringFormatter.toString(e),
|
StringFormatter.toString(e),
|
||||||
|
|
|
@ -141,7 +141,7 @@ class GeneralTab(window: InstanceSettingsWindow) : SectionedSettingsTab<Instance
|
||||||
try {
|
try {
|
||||||
dialog.setFile(File.newForPath(instance.meta.java))
|
dialog.setFile(File.newForPath(instance.meta.java))
|
||||||
} catch (e: GErrorException) {
|
} catch (e: GErrorException) {
|
||||||
Utils.LOGGER.error("Could not set starting point", e)
|
Log.error("Could not set starting point", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.onResponse { responseId: Int ->
|
dialog.onResponse { responseId: Int ->
|
||||||
|
|
Loading…
Reference in New Issue