Skip to content

Commit 0c18c32

Browse files
committed
Improve logging
CHECK: Any side effects of making log methods static?
1 parent 04bafd2 commit 0c18c32

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

addons/Comedot/Comedot.gd

+18-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ static func printLog(message: String) -> void:
4747
print(str("Comedot: ", message)) # Extra space to align with "Comedock: " :)
4848

4949

50+
static func printWarning(message: String) -> void:
51+
var warningMessage: String = str("Comedot: WARNING: ", message)
52+
print(warningMessage)
53+
push_warning(warningMessage)
54+
55+
56+
static func printError(message: String) -> void:
57+
var errorMessage: String = str("Comedot: WARNING: ", message)
58+
print(errorMessage)
59+
push_error(errorMessage)
60+
61+
5062
#region Custom Types
5163

5264
func addCustomTypes() -> void:
@@ -148,17 +160,17 @@ static func verifyAllComponents(rootPath: String = "res://Components") -> bool:
148160
if doesFilenameEndInComponent:
149161
# TEST 1: Does the filename end in "Component" but cannot be instantiated?
150162
if not scene:
151-
printLog("Cannot load Component Scene: " + file)
163+
printError("Cannot load Component Scene: " + file)
152164
areAllComponentsOK = false
153165
continue
154166
elif not instance or not is_instance_valid(instance):
155-
printLog("Cannot instantiate Component Scene: " + file)
167+
printError("Cannot instantiate Component Scene: " + file)
156168
areAllComponentsOK = false
157169
continue
158170

159171
# TEST 2: Is the file named "…Component" but is not a Component object?
160172
elif not is_instance_of(instance, Component):
161-
printLog("Filename ends in \"Component\" but Object Type is not Component: " + file)
173+
printWarning("Filename ends in \"Component\" but Object Type is not Component: " + file)
162174
areAllComponentsOK = false
163175
continue
164176

@@ -167,11 +179,12 @@ static func verifyAllComponents(rootPath: String = "res://Components") -> bool:
167179

168180
# TEST 3: Is it in the "Components" Group?
169181
if not instance.is_in_group(Global.Groups.components):
170-
printLog("Component root node is not in \"" + Global.Groups.components + "\" group: " + file)
182+
printWarning("Component root node is not in \"" + Global.Groups.components + "\" group: " + file)
171183
areAllComponentsOK = false
172184
continue
173185

174-
printLog(str("verifyAllComponents(): ", count, " components checked. All OK? ", areAllComponentsOK))
186+
if areAllComponentsOK: printLog(str("verifyAllComponents(): ", count, " components checked. All OK."))
187+
else: printWarning(str("verifyAllComponents(): ", count, " components checked. SOME TESTS FAILED!"))
175188
return areAllComponentsOK
176189

177190
#endregion

addons/Comedot/ComponentsDock.gd

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ func _ready() -> void:
126126
setupUI()
127127

128128

129-
func printLog(message: String) -> void:
129+
static func printLog(message: String) -> void:
130130
print(str("Comedock: ", message))
131131

132132

133-
func printError(message: String) -> void:
133+
static func printError(message: String) -> void:
134134
var errorMessage: String = str("Comedock: ERROR: ", message)
135135
print(errorMessage)
136136
push_error(errorMessage)

0 commit comments

Comments
 (0)