From 543247e721a5ca1c3b3fb1bf8b9f28574c8fdb75 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 24 Jul 2019 11:19:10 +0200 Subject: [PATCH] feat(core/debug): add log functions --- CHANGELOG.md | 2 ++ gamecore/debug.lua | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f16796..cde4cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add a gamesystem module +- **core/debug:** add log functions + ### Changed - **world:** extract map module from the world module diff --git a/gamecore/debug.lua b/gamecore/debug.lua index fe6076d..0c1097a 100644 --- a/gamecore/debug.lua +++ b/gamecore/debug.lua @@ -36,4 +36,26 @@ function DebugSystem:update(dt) lovebird.update(dt) end +-- PRINT FUNCTIONS +-- Print and log debug string + +function DebugSystem:print(context, string) + if (self.active) then + print("[DEBUG] ".. context .. ": " .. string) + end +end + +function DebugSystem:warning(context, string) + if (self.active) then + print("[WARNING] " .. context .. ": " .. string) + end +end + +function DebugSystem:error(context, string) + if (self.active) then + error("[ERROR] " .. context .. ": " .. string) + end +end + + return DebugSystem