add debug log command
Some checks are pending
Java CI with Gradle / build (push) Waiting to run

This commit is contained in:
alexcrea 2026-06-29 00:56:54 +02:00
parent fcbe6ba3fb
commit 965ee33325
Signed by: alexcrea
GPG key ID: E346CD16413450E3
5 changed files with 140 additions and 2 deletions

View file

@ -71,21 +71,35 @@ open class CustomAnvil : JavaPlugin() {
var latestVer: String? = null
// Debug
val debugStorageQueue = ArrayDeque<String>()
private fun addToLogQueue(message: String) {
if(debugStorageQueue.size >= 200) {
// Let not store infinite debug logs lol
debugStorageQueue.removeFirst()
}
debugStorageQueue.addLast(message)
}
/**
* Logging handler
*/
@JvmStatic fun log(message: String) {
if (ConfigOptions.debugLog) {
instance.logger.info(message)
addToLogQueue(message)
}
}
/**
* Vebose Logging handler
*/
fun verboseLog(message: String) {
@JvmStatic fun verboseLog(message: String) {
if (ConfigOptions.verboseDebugLog) {
instance.logger.info(message)
addToLogQueue(message)
}
}

View file

@ -128,6 +128,9 @@ object ConfigOptions {
private const val DEFAULT_DEBUG_LOG = false
private const val DEFAULT_VERBOSE_DEBUG_LOG = false
var OVERRIDE_DEBUG_LOG: Boolean? = null
var OVERRIDE_VERBOSE_DEBUG_LOG: Boolean? = null
// Dialog menu rename
const val DEFAULT_DIALOG_RENAME_ENABLED = false
const val DEFAULT_DIALOG_MAX_SIZE = 256
@ -436,6 +439,9 @@ object ConfigOptions {
*/
val debugLog: Boolean
get() {
val overrider = OVERRIDE_DEBUG_LOG
if(overrider != null) return overrider
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(DEBUG_LOGGING, DEFAULT_DEBUG_LOG)
@ -446,6 +452,9 @@ object ConfigOptions {
*/
val verboseDebugLog: Boolean
get() {
val overrider = OVERRIDE_VERBOSE_DEBUG_LOG
if(overrider != null) return overrider
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(VERBOSE_DEBUG_LOGGING, DEFAULT_VERBOSE_DEBUG_LOG)