mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
more log level refactoring
This commit is contained in:
parent
06f21f6de8
commit
52d285cb65
@ -15,10 +15,11 @@ package de.bixilon.minosoft.config.config.general
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import de.bixilon.minosoft.config.Configuration
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
data class GeneralConfig(
|
||||
var version: Int = Configuration.LATEST_CONFIG_VERSION,
|
||||
@Json(name = "enabled_log_types") var enabledLogTypes: MutableSet<LogMessageType> = LogMessageType.DEFAULT_LOG_MESSAGE_TYPES.toMutableSet(),
|
||||
@Json(name = "log") var log: MutableMap<LogMessageType, LogLevels> = LogMessageType.DEFAULT_LOG_MAP.toMutableMap(),
|
||||
var language: String = "en_US",
|
||||
)
|
||||
|
@ -17,7 +17,8 @@ import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.StaticConfiguration
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.Util
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.io.*
|
||||
import java.nio.file.Files
|
||||
@ -58,7 +59,7 @@ interface FileAssetsManager : AssetsManager {
|
||||
hash == Util.sha1(File(getAssetDiskPath(hash)))
|
||||
}
|
||||
} catch (exception: IOException) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = exception)
|
||||
Log.log(LogMessageType.ASSETS, level = LogLevels.VERBOSE, message = exception)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -74,7 +75,7 @@ interface FileAssetsManager : AssetsManager {
|
||||
if (checkURL) {
|
||||
Util.checkURL(url)
|
||||
}
|
||||
log(LogMessageType.OTHER_DEBUG, message = "Downloading %s -> %s", formatting = arrayOf<Any>(url, hash))
|
||||
Log.log(LogMessageType.ASSETS, level = LogLevels.VERBOSE, message = "Downloading %s -> %s", formatting = arrayOf<Any>(url, hash))
|
||||
if (compress) {
|
||||
Util.downloadFileAsGz(url, getAssetDiskPath(hash))
|
||||
return
|
||||
|
@ -29,7 +29,8 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.BitByte
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.enum.ValuesEnum
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3i
|
||||
import java.util.*
|
||||
@ -128,7 +129,7 @@ class EntityMetaData(
|
||||
try {
|
||||
return it as K
|
||||
} catch (e: ClassCastException) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = e)
|
||||
Log.log(LogMessageType.OTHER, level = LogLevels.WARN, message = e)
|
||||
}
|
||||
}
|
||||
return field.getDefaultValue()
|
||||
|
@ -24,7 +24,8 @@ import de.bixilon.minosoft.protocol.protocol.PacketTypes.S2C
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.util.Util
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
data class Version(
|
||||
@ -85,7 +86,7 @@ data class Version(
|
||||
}
|
||||
latch.countUp()
|
||||
isGettingLoaded = true
|
||||
log(LogMessageType.OTHER_DEBUG, message = String.format("Loading mappings for version %s...", this), formatting = arrayOf())
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.INFO) { "Loading mappings for $this..." }
|
||||
initializeAssetManger(latch)
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
||||
@ -99,7 +100,7 @@ data class Version(
|
||||
Util.readJsonFromStream(assetsManager.readAssetAsStream(Resources.getPixLyzerDataHashByVersion(this)))
|
||||
} catch (exception: Throwable) {
|
||||
// should not happen, but if this version is not flattened, we can fallback to the flatten mappings. Some things might not work...
|
||||
log(LogMessageType.OTHER_DEBUG, message = exception)
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.VERBOSE) { exception }
|
||||
if (isFlattened()) {
|
||||
throw exception
|
||||
}
|
||||
@ -112,9 +113,9 @@ data class Version(
|
||||
mapping.load(this, pixlyzerData)
|
||||
latch.countDown()
|
||||
if (pixlyzerData.size() > 0) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = String.format("Loaded mappings for version %s in %dms (%s)", this, (System.currentTimeMillis() - startTime), versionName), formatting = arrayOf())
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.INFO) { "Loaded mappings for $this (${versionName} in ${System.currentTimeMillis() - startTime}ms" }
|
||||
} else {
|
||||
log(LogMessageType.OTHER_DEBUG, message = String.format("Could not load mappings for version %s. Some features will be unavailable.", this), formatting = arrayOf())
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.WARN) { "Could not load mappings for $this (${versionName}. Some features might not work." }
|
||||
}
|
||||
isLoaded = true
|
||||
isGettingLoaded = false
|
||||
|
@ -37,7 +37,7 @@ import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.PositionAndRotationS2CP
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec2.Vec2i
|
||||
@ -113,6 +113,7 @@ class RenderWindow(
|
||||
}
|
||||
|
||||
fun init(latch: CountUpAndDownLatch) {
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Creating window..." }
|
||||
// Setup an error callback. The default implementation
|
||||
// will print the error message in System.err.
|
||||
GLFWErrorCallback.createPrint(System.err).set()
|
||||
@ -164,6 +165,7 @@ class RenderWindow(
|
||||
glfwSetWindowPos(windowId, (videoMode.width() - pWidth[0]) / 2, (videoMode.height() - pHeight[0]) / 2)
|
||||
}
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Creating context..." }
|
||||
// Make the OpenGL context current
|
||||
glfwMakeContextCurrent(windowId)
|
||||
// Enable v-sync
|
||||
@ -175,6 +177,7 @@ class RenderWindow(
|
||||
|
||||
setSkyColor(RGBColor("#fffe7a"))
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Enabling all open gl features..." }
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glEnable(GL_BLEND)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
@ -182,6 +185,7 @@ class RenderWindow(
|
||||
glEnable(GL_CULL_FACE)
|
||||
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Generating font and textures..." }
|
||||
textures.allTextures.add(Texture(RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION))
|
||||
WHITE_TEXTURE = TextureLikeTexture(
|
||||
texture = Texture(ResourceLocation("minosoft:textures/white.png")),
|
||||
@ -195,16 +199,20 @@ class RenderWindow(
|
||||
|
||||
font.preLoadAtlas(textures)
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Initializing renderer..." }
|
||||
for (renderer in rendererMap.values) {
|
||||
renderer.init()
|
||||
}
|
||||
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Preloading textures..." }
|
||||
textures.preLoad(connection.assetsManager)
|
||||
|
||||
font.loadAtlas()
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Loading textures..." }
|
||||
textures.load()
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Post loading renderer..." }
|
||||
for (renderer in rendererMap.values) {
|
||||
renderer.postInit()
|
||||
if (renderer is ShaderHolder) {
|
||||
@ -213,6 +221,7 @@ class RenderWindow(
|
||||
}
|
||||
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Registering glfw callbacks..." }
|
||||
glfwSetWindowSizeCallback(windowId, object : GLFWWindowSizeCallback() {
|
||||
override fun invoke(window: Long, width: Int, height: Int) {
|
||||
glViewport(0, 0, width, height)
|
||||
@ -254,11 +263,12 @@ class RenderWindow(
|
||||
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
|
||||
log(LogMessageType.OTHER_DEBUG, message = "Rendering is prepared and ready to go!", formatting = arrayOf())
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Rendering is fully prepared" }
|
||||
latch.countDown()
|
||||
latch.waitUntilZero()
|
||||
this.latch.waitUntilZero()
|
||||
glfwShowWindow(windowId)
|
||||
Log.log(LogMessageType.RENDERING_GENERAL) { "Showing window" }
|
||||
}
|
||||
|
||||
private fun registerGlobalKeyCombinations() {
|
||||
@ -280,6 +290,7 @@ class RenderWindow(
|
||||
}
|
||||
|
||||
fun startRenderLoop() {
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Starting loop" }
|
||||
while (!glfwWindowShouldClose(windowId)) {
|
||||
if (renderingState == RenderingStates.PAUSED) {
|
||||
Thread.sleep(100L)
|
||||
@ -343,6 +354,7 @@ class RenderWindow(
|
||||
}
|
||||
|
||||
fun exit() {
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Destroying render window..." }
|
||||
// Free the window callbacks and destroy the window
|
||||
Callbacks.glfwFreeCallbacks(windowId)
|
||||
glfwDestroyWindow(windowId)
|
||||
@ -351,6 +363,7 @@ class RenderWindow(
|
||||
glfwTerminate()
|
||||
glfwSetErrorCallback(null)!!.free()
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Render window destroyed!" }
|
||||
// disconnect
|
||||
connection.disconnect()
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ import de.bixilon.minosoft.terminal.commands.commands.Command
|
||||
import de.bixilon.minosoft.util.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.util.ServerAddress
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.time.TimeWorker
|
||||
import de.bixilon.minosoft.util.time.TimeWorkerTask
|
||||
@ -158,11 +158,11 @@ class PlayConnection(
|
||||
}
|
||||
latch.waitForChange()
|
||||
}
|
||||
log(LogMessageType.OTHER_INFO, message = "Connecting to server: $address", formatting = arrayOf())
|
||||
Log.log(LogMessageType.NETWORK_STATUS, level = LogLevels.INFO) { "Connecting to server: $address" }
|
||||
network.connect(address)
|
||||
} catch (exception: Throwable) {
|
||||
Log.log(LogMessageType.VERSION_LOADING) { exception }
|
||||
log(LogMessageType.OTHER_FATAL, message = "Could not load version $version. This version seems to be unsupported!", formatting = arrayOf())
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { exception }
|
||||
Log.log(LogMessageType.VERSION_LOADING, level = LogLevels.FATAL) { "Could not load version $version. This version seems to be unsupported" }
|
||||
version.unload()
|
||||
lastException = MappingsLoadingException("Mappings could not be loaded", exception)
|
||||
connectionState = ConnectionStates.FAILED_NO_RETRY
|
||||
@ -200,7 +200,7 @@ class PlayConnection(
|
||||
packet.handle(this)
|
||||
}
|
||||
} catch (exception: Throwable) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN_ERROR) { exception }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.WARN) { exception }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import de.bixilon.minosoft.protocol.protocol.Protocol
|
||||
import de.bixilon.minosoft.util.DNSUtil
|
||||
import de.bixilon.minosoft.util.ServerAddress
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.util.*
|
||||
|
||||
@ -142,7 +143,7 @@ class StatusConnection(
|
||||
packet.handle(this)
|
||||
}
|
||||
} catch (exception: Throwable) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN_ERROR) { exception }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.WARN) { exception }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
||||
import de.bixilon.minosoft.util.Pair;
|
||||
import de.bixilon.minosoft.util.ServerAddress;
|
||||
import de.bixilon.minosoft.util.logging.Log;
|
||||
import de.bixilon.minosoft.util.logging.LogLevels;
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
@ -107,7 +108,7 @@ public class BlockingSocketNetwork extends Network {
|
||||
var typeAndPacket = prepareS2CPacket(this.inputStream);
|
||||
handlePacket(typeAndPacket.getKey(), typeAndPacket.getValue());
|
||||
} catch (PacketParseException e) {
|
||||
Log.printException(e, LogMessageType.NETWORK_PACKETS_IN_ERROR);
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, e);
|
||||
}
|
||||
}
|
||||
this.connection.disconnect();
|
||||
@ -121,7 +122,7 @@ public class BlockingSocketNetwork extends Network {
|
||||
this.connection.setConnectionState(ConnectionStates.DISCONNECTED);
|
||||
return;
|
||||
}
|
||||
Log.printException(exception, LogMessageType.NETWORK_PACKETS_IN_ERROR);
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, exception);
|
||||
this.connection.setLastException(exception);
|
||||
this.connection.setConnectionState(ConnectionStates.FAILED);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
||||
import de.bixilon.minosoft.util.ServerAddress;
|
||||
import de.bixilon.minosoft.util.logging.Log;
|
||||
import de.bixilon.minosoft.util.logging.LogLevels;
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
@ -140,7 +141,7 @@ public class NonBlockingSocketNetwork extends Network {
|
||||
var typeAndPacket = receiveS2CPacket(decryptData(currentPacketBuffer.array()));
|
||||
handlePacket(typeAndPacket.getKey(), typeAndPacket.getValue());
|
||||
} catch (PacketParseException e) {
|
||||
Log.printException(e, LogMessageType.NETWORK_PACKETS_IN_ERROR);
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, e);
|
||||
}
|
||||
currentPacketBuffer.clear();
|
||||
currentPacketBuffer = null;
|
||||
@ -159,7 +160,7 @@ public class NonBlockingSocketNetwork extends Network {
|
||||
if (exception instanceof SocketException && exception.getMessage().equals("Socket closed")) {
|
||||
return;
|
||||
}
|
||||
Log.printException(exception, LogMessageType.NETWORK_PACKETS_IN_ERROR);
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN, exception);
|
||||
this.connection.setLastException(exception);
|
||||
this.connection.setConnectionState(ConnectionStates.FAILED);
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ class HandshakeC2SPacket(
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT) { "Handshake packet" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT) { "Handshake" }
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
import glm_.vec3.Vec3i
|
||||
@ -42,6 +43,6 @@ class BlockEntityMetaDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Block entity meta data (position=$position, type=$type, nbt=$nbt)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Block entity meta data (position=$position, type=$type, nbt=$nbt)" }
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
@ -61,6 +62,6 @@ class BlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Block change (position=${blockPosition}, block=$block)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Block change (position=${blockPosition}, block=$block)" }
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.util.*
|
||||
|
||||
@ -51,10 +52,10 @@ class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
ChatTextPositions.ABOVE_HOTBAR -> "[HOTBAR] "
|
||||
else -> ""
|
||||
}
|
||||
Log.log(LogMessageType.CHAT_IN, ChatComponent.valueOf(raw = additionalPrefix)) { event.message }
|
||||
Log.log(LogMessageType.CHAT_IN, additionalPrefix = ChatComponent.valueOf(raw = additionalPrefix)) { event.message }
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Received chat message (message=\"$message\")" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Received chat message (message=\"$message\")" }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import de.bixilon.minosoft.util.KUtil.nullCast
|
||||
import de.bixilon.minosoft.util.Util
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
import glm_.vec2.Vec2i
|
||||
@ -108,7 +108,7 @@ class ChunkDataS2CP() : PlayS2CPacket() {
|
||||
val position = Vec3i(nbt["x"]?.nullCast<Int>()!!, nbt["y"]?.nullCast<Int>()!!, nbt["z"]?.nullCast<Int>()!!)
|
||||
val resourceLocation = ResourceLocation(nbt["id"]?.nullCast<String>()!!)
|
||||
val type = buffer.connection.mapping.blockEntityRegistry.get(resourceLocation) ?: let {
|
||||
log(LogMessageType.OTHER_ERROR, message = "Unknown block entity $resourceLocation", formatting = arrayOf())
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.WARN) { "Unknown block entity: $resourceLocation" }
|
||||
null
|
||||
} ?: continue
|
||||
val entity = type.build(buffer.connection) ?: continue
|
||||
@ -140,6 +140,6 @@ class ChunkDataS2CP() : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Chunk data (chunkPosition=$chunkPosition)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Chunk data (chunkPosition=$chunkPosition)" }
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.chunk.LightUtil.readLightPacket
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec2.Vec2i
|
||||
import java.util.*
|
||||
@ -57,7 +58,7 @@ class ChunkLightDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Chunk light data (position=$chunkPosition)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Chunk light data (position=$chunkPosition)" }
|
||||
}
|
||||
|
||||
override fun handle(connection: PlayConnection) {
|
||||
|
@ -17,6 +17,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.enum.ValuesEnum
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class EntityAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
@ -25,7 +26,7 @@ class EntityAnimationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Play entity animation (entityId=$entityId, animation=$animation)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Play entity animation (entityId=$entityId, animation=$animation)" }
|
||||
}
|
||||
|
||||
enum class EntityAnimations {
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class EntityMetadataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
@ -37,6 +38,6 @@ class EntityMetadataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "[IN] Received entity metadata (entityId=$entityId)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "[IN] Received entity metadata (entityId=$entityId)" }
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3
|
||||
|
||||
@ -30,6 +31,6 @@ class EntityVelocityS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "[IN] Entity velocity changed(entityId=$entityId, velocity=$velocity)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "[IN] Entity velocity changed(entityId=$entityId, velocity=$velocity)" }
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
@ -29,6 +30,6 @@ class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Slot change (slot=$slot)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Slot change (slot=$slot)" }
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W27A
|
||||
import de.bixilon.minosoft.util.BitByte
|
||||
import de.bixilon.minosoft.util.KUtil.nullCast
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.listCast
|
||||
@ -178,7 +179,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Join game packet (entityId=$entityId, gamemode=$gamemode, dimension=$dimension, difficulty=$difficulty, hardcore=$isHardcore, viewDistance=$viewDistance)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Join game packet (entityId=$entityId, gamemode=$gamemode, dimension=$dimension, difficulty=$difficulty, hardcore=$isHardcore, viewDistance=$viewDistance)" }
|
||||
}
|
||||
|
||||
companion object : ErrorHandler {
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec2.Vec2i
|
||||
import glm_.vec3.Vec3i
|
||||
@ -99,6 +100,6 @@ class MassBlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Multi block change (chunkPosition=${chunkPosition}, count=${blocks.size})" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Multi block change (chunkPosition=${chunkPosition}, count=${blocks.size})" }
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.Util
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec2.Vec2i
|
||||
import java.util.*
|
||||
@ -87,6 +88,6 @@ class MassChunkDataS2CP() : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Mass chunk data (chunks=${data.size})" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Mass chunk data (chunks=${data.size})" }
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
|
||||
@ -23,6 +24,6 @@ class NBTQueryResponseS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
val nbt: Map<String, Any> = buffer.readNBT()?.compoundCast()!!
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "NBT query response (transactionId=$transactionId nbt=$nbt)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "NBT query response (transactionId=$transactionId nbt=$nbt)" }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.BitByte.isBit
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
@ -45,7 +46,7 @@ class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Player abilities: (isInvulnerable=$isInvulnerable, isFlying=$isFlying, canFly=$canFly, canInstantBuild=$canInstantBuild, flyingSpeed=$flyingSpeed, walkingSpeed=$walkingSpeed)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Player abilities: (isInvulnerable=$isInvulnerable, isFlying=$isFlying, canFly=$canFly, canInstantBuild=$canInstantBuild, flyingSpeed=$flyingSpeed, walkingSpeed=$walkingSpeed)" }
|
||||
}
|
||||
|
||||
override fun handle(connection: PlayConnection) {
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.BitByte
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3
|
||||
|
||||
@ -81,6 +82,6 @@ class PositionAndRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Player position (position=$position, rotation=$rotation, onGround=$isOnGround)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Player position (position=$position, rotation=$rotation, onGround=$isOnGround)" }
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.compoundCast
|
||||
|
||||
@ -94,6 +95,6 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Respawn (dimension=$dimension, difficulty=$difficulty, gamemode=$gamemode, levelType=$levelType)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Respawn (dimension=$dimension, difficulty=$difficulty, gamemode=$gamemode, levelType=$levelType)" }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
@ -37,6 +38,6 @@ class ServerDifficultyS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Server difficulty (difficulty=$difficulty, locked=${locked})" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Server difficulty (difficulty=$difficulty, locked=${locked})" }
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class SetExperienceS2CP() : PlayS2CPacket() {
|
||||
@ -55,6 +56,6 @@ class SetExperienceS2CP() : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Level update (bar=$bar, level=$level, total=$total)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Level update (bar=$bar, level=$level, total=$total)" }
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
@ -52,6 +53,6 @@ class SetSignTextS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Sign data (position=$signPosition, lines=$lines" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Sign data (position=$signPosition, lines=$lines" }
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.Util
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3
|
||||
import java.util.*
|
||||
@ -78,7 +78,7 @@ class SpawnPlayerS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
if (metaData != null) {
|
||||
entity.entityMetaData = metaData
|
||||
if (StaticConfiguration.VERBOSE_ENTITY_META_DATA_LOGGING) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = String.format("Metadata of entity %s (entityId=%d): %s", entity.toString(), entityId, entity.entityMetaDataAsString), formatting = arrayOf())
|
||||
Log.log(LogMessageType.OTHER, level = LogLevels.VERBOSE) { "Players metadata of $entity: ${entity.entityMetaData}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,6 +91,6 @@ class SpawnPlayerS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Player spawned (position=${entity.position}, entityId=$entityId, name=${entity.name}, uuid=$entityUUID)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Player spawned (position=${entity.position}, entityId=$entityId, name=${entity.name}, uuid=$entityUUID)" }
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.*
|
||||
@ -174,7 +175,7 @@ class TabListItemS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "Received tab list items: $items" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Received tab list items: $items" }
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec3.Vec3i
|
||||
|
||||
@ -30,6 +31,6 @@ class WorldEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
val isGlobal: Boolean = buffer.readBoolean()
|
||||
|
||||
override fun log() {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN) { "World event packet (position=$position, eventId=$eventId, data=$data, isGlobal=$isGlobal)" }
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "World event packet (position=$position, eventId=$eventId, data=$data, isGlobal=$isGlobal)" }
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ package de.bixilon.minosoft.util
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.logging.Log.log
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
@ -103,8 +104,8 @@ object GitInfo {
|
||||
|
||||
IS_INITIALIZED = true
|
||||
} catch (exception: Throwable) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = exception)
|
||||
log(LogMessageType.OTHER_ERROR, message = "Can not load git information.", formatting = arrayOf())
|
||||
Log.log(LogMessageType.OTHER, level = LogLevels.WARN) { exception }
|
||||
Log.log(LogMessageType.OTHER, level = LogLevels.WARN) { "Could not load git information." }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ object Log {
|
||||
private val LOG_QUEUE = LinkedBlockingQueue<MessageToSend>()
|
||||
private val SYSTEM_ERR_STREAM = System.err
|
||||
private val SYSTEM_OUT_STREAM = System.out
|
||||
private val ERROR_PRINT_STREAM: PrintStream = LogPrintStream(LogMessageType.OTHER_ERROR)
|
||||
private val OUT_PRINT_STREAM: PrintStream = LogPrintStream(LogMessageType.OTHER_INFO)
|
||||
private val ERROR_PRINT_STREAM: PrintStream = LogPrintStream(LogMessageType.OTHER, LogLevels.WARN)
|
||||
private val OUT_PRINT_STREAM: PrintStream = LogPrintStream(LogMessageType.OTHER, LogLevels.INFO)
|
||||
|
||||
|
||||
init {
|
||||
@ -48,11 +48,12 @@ object Log {
|
||||
message.parts.add(TextComponent("[${TIME_FORMAT.format(messageToSend.time)}] "))
|
||||
message.parts.add(TextComponent("[${messageToSend.thread.name}] "))
|
||||
message.parts.add(TextComponent("[${messageToSend.logMessageType}] "))
|
||||
message.parts.add(TextComponent("[${messageToSend.level}] "))
|
||||
messageToSend.additionalPrefix?.let {
|
||||
message.parts.add(it)
|
||||
}
|
||||
message.parts.add(messageToSend.message)
|
||||
message.applyDefaultColor(messageToSend.logMessageType.color)
|
||||
message.applyDefaultColor(messageToSend.logMessageType.colorMap[messageToSend.level] ?: messageToSend.logMessageType.defaultColor)
|
||||
|
||||
val stream = if (messageToSend.logMessageType.error) {
|
||||
SYSTEM_ERR_STREAM
|
||||
@ -71,9 +72,13 @@ object Log {
|
||||
@DoNotCall
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun log(logMessageType: LogMessageType, additionalPrefix: ChatComponent? = null, message: Any, vararg formatting: Any) {
|
||||
if (Minosoft.config != null && !Minosoft.config.config.general.enabledLogTypes.contains(logMessageType)) {
|
||||
return
|
||||
fun log(logMessageType: LogMessageType, level: LogLevels = LogLevels.INFO, additionalPrefix: ChatComponent? = null, message: Any, vararg formatting: Any) {
|
||||
if (Minosoft.config != null) {
|
||||
Minosoft.config.config.general.log[logMessageType]?.let {
|
||||
if (it.ordinal < level.ordinal) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
val formattedMessage = when (message) {
|
||||
is ChatComponent -> message
|
||||
@ -91,6 +96,7 @@ object Log {
|
||||
message = formattedMessage,
|
||||
time = System.currentTimeMillis(),
|
||||
logMessageType = logMessageType,
|
||||
level = level,
|
||||
thread = Thread.currentThread(),
|
||||
additionalPrefix = additionalPrefix,
|
||||
)
|
||||
@ -98,11 +104,20 @@ object Log {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun log(logMessageType: LogMessageType, additionalPrefix: ChatComponent? = null, messageBuilder: () -> Any) {
|
||||
if (!Minosoft.config.config.general.enabledLogTypes.contains(logMessageType)) {
|
||||
return
|
||||
fun log(logMessageType: LogMessageType, level: LogLevels = LogLevels.INFO, additionalPrefix: ChatComponent? = null, messageBuilder: () -> Any) {
|
||||
if (Minosoft.config != null) {
|
||||
Minosoft.config.config.general.log[logMessageType]?.let {
|
||||
if (it.ordinal < level.ordinal) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
log(logMessageType, additionalPrefix, messageBuilder.invoke())
|
||||
log(logMessageType, level, additionalPrefix, messageBuilder.invoke())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun log(logMessageType: LogMessageType, level: LogLevels, messageBuilder: () -> Any) {
|
||||
log(logMessageType, level = level, additionalPrefix = null, messageBuilder = messageBuilder)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -110,63 +125,69 @@ object Log {
|
||||
log(logMessageType, additionalPrefix = null, messageBuilder = messageBuilder)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(logMessageType, message = exception)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun printException(exception: Throwable, logMessageType: LogMessageType, level: LogLevels) {
|
||||
log(logMessageType, level = level, message = exception)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun printException(exception: Throwable, logMessageType: LogMessageType) {
|
||||
log(logMessageType, message = exception)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_FATAL, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun fatal(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_FATAL, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.FATAL, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_ERROR, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun error(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_ERROR, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.WARN, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun info(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.INFO, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_DEBUG, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun debug(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.VERBOSE, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_DEBUG, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun verbose(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_DEBUG, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.VERBOSE, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.NETWORK_PACKETS_IN, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun protocol(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.NETWORK_PACKETS_IN, message = message, formatting = formatting)
|
||||
log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_ERROR, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun warn(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_ERROR, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.WARN, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun game(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.INFO, message = message, formatting = formatting)
|
||||
}
|
||||
|
||||
@Deprecated(message = "Java only", replaceWith = ReplaceWith("log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)", "de.bixilon.minosoft.util.logging.Log.log"))
|
||||
@Deprecated(message = "Java only")
|
||||
@JvmStatic
|
||||
fun mojang(message: Any, vararg formatting: Any) {
|
||||
log(LogMessageType.OTHER_INFO, message = message, formatting = formatting)
|
||||
log(LogMessageType.OTHER, level = LogLevels.INFO, message = message, formatting = formatting)
|
||||
}
|
||||
}
|
||||
|
22
src/main/java/de/bixilon/minosoft/util/logging/LogLevels.kt
Normal file
22
src/main/java/de/bixilon/minosoft/util/logging/LogLevels.kt
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util.logging
|
||||
|
||||
enum class LogLevels {
|
||||
FATAL,
|
||||
WARN,
|
||||
INFO,
|
||||
VERBOSE,
|
||||
;
|
||||
}
|
@ -18,8 +18,9 @@ import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.enum.ValuesEnum
|
||||
|
||||
enum class LogMessageType(
|
||||
val color: RGBColor,
|
||||
val enabledDefault: Boolean = true,
|
||||
val defaultColor: RGBColor,
|
||||
val colorMap: Map<LogLevels, RGBColor> = mapOf(),
|
||||
val defaultLevel: LogLevels = LogLevels.INFO,
|
||||
val error: Boolean = false,
|
||||
) {
|
||||
GENERAL(ChatColors.WHITE),
|
||||
@ -27,12 +28,18 @@ enum class LogMessageType(
|
||||
JAVAFX(ChatColors.DARK_GRAY),
|
||||
|
||||
VERSION_LOADING(ChatColors.YELLOW),
|
||||
ASSETS(ChatColors.BLACK),
|
||||
|
||||
NETWORK_RESOLVING(ChatColors.DARK_GREEN),
|
||||
NETWORK_STATUS(ChatColors.DARK_GREEN, enabledDefault = false),
|
||||
NETWORK_PACKETS_IN(ChatColors.BLUE, enabledDefault = false),
|
||||
NETWORK_PACKETS_IN_ERROR(ChatColors.RED, error = true),
|
||||
NETWORK_PACKETS_OUT(ChatColors.DARK_AQUA, enabledDefault = false),
|
||||
NETWORK_STATUS(ChatColors.DARK_GREEN),
|
||||
NETWORK_PACKETS_IN(ChatColors.BLUE, mapOf(
|
||||
LogLevels.FATAL to ChatColors.DARK_RED,
|
||||
LogLevels.WARN to ChatColors.RED,
|
||||
), defaultLevel = LogLevels.WARN),
|
||||
NETWORK_PACKETS_OUT(ChatColors.DARK_AQUA, mapOf(
|
||||
LogLevels.FATAL to ChatColors.DARK_RED,
|
||||
LogLevels.WARN to ChatColors.RED,
|
||||
), defaultLevel = LogLevels.WARN),
|
||||
|
||||
RENDERING_GENERAL(ChatColors.GREEN),
|
||||
RENDERING_LOADING(ChatColors.GREEN),
|
||||
@ -40,25 +47,25 @@ enum class LogMessageType(
|
||||
CHAT_IN(ChatColors.LIGHT_PURPLE),
|
||||
CHAT_OUT(ChatColors.LIGHT_PURPLE),
|
||||
|
||||
OTHER_INFO(ChatColors.WHITE),
|
||||
OTHER_DEBUG(ChatColors.YELLOW),
|
||||
OTHER_ERROR(ChatColors.RED, error = true),
|
||||
OTHER_FATAL(ChatColors.DARK_RED, error = true),
|
||||
OTHER(ChatColors.WHITE, mapOf(
|
||||
LogLevels.FATAL to ChatColors.DARK_RED,
|
||||
LogLevels.WARN to ChatColors.RED,
|
||||
LogLevels.VERBOSE to ChatColors.YELLOW,
|
||||
)),
|
||||
;
|
||||
|
||||
companion object : ValuesEnum<LogMessageType> {
|
||||
override val VALUES: Array<LogMessageType> = values()
|
||||
override val NAME_MAP: Map<String, LogMessageType> = KUtil.getEnumValues(VALUES)
|
||||
|
||||
val DEFAULT_LOG_MESSAGE_TYPES = let {
|
||||
val ret: MutableSet<LogMessageType> = mutableSetOf()
|
||||
val DEFAULT_LOG_MAP: Map<LogMessageType, LogLevels> = let {
|
||||
val ret: MutableMap<LogMessageType, LogLevels> = mutableMapOf()
|
||||
|
||||
for (value in VALUES) {
|
||||
if (value.enabledDefault) {
|
||||
ret += value
|
||||
}
|
||||
ret[value] = value.defaultLevel
|
||||
}
|
||||
ret.toSet()
|
||||
|
||||
ret.toMap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,12 @@ package de.bixilon.minosoft.util.logging
|
||||
|
||||
import java.io.PrintStream
|
||||
|
||||
class LogPrintStream(private val level: LogMessageType) : PrintStream(nullOutputStream()) {
|
||||
class LogPrintStream(
|
||||
val type: LogMessageType = LogMessageType.OTHER,
|
||||
val level: LogLevels,
|
||||
) : PrintStream(nullOutputStream()) {
|
||||
|
||||
override fun print(string: String) {
|
||||
Log.log(message = string, logMessageType = level)
|
||||
Log.log(message = string, logMessageType = type, level = level)
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ data class MessageToSend(
|
||||
val message: ChatComponent,
|
||||
val time: Long,
|
||||
val logMessageType: LogMessageType,
|
||||
val level: LogLevels,
|
||||
val thread: Thread,
|
||||
val additionalPrefix: ChatComponent? = null,
|
||||
)
|
||||
|
@ -51,7 +51,7 @@ public final class MojangAuthentication {
|
||||
try {
|
||||
response = HTTP.postJson(ProtocolDefinition.MOJANG_URL_LOGIN, payload);
|
||||
} catch (IOException | InterruptedException e) {
|
||||
Log.printException(e, LogMessageType.OTHER_INFO);
|
||||
Log.printException(e, LogMessageType.OTHER);
|
||||
throw new NoNetworkConnectionException(e);
|
||||
}
|
||||
if (response == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user