@@ -43,8 +43,13 @@ static var verbosity: VERBOSITY_LEVEL = VERBOSITY_LEVEL.DEBUG
4343## Array of mods that should be ignored when logging messages (contains mod IDs as strings)
4444static var ignored_mods : Array [String ] = []
4545
46- ## Highlighting color for hint type log messages
47- static var hint_color := Color ("#70bafa" )
46+ # NOTE: default values which get replaced later by `_configure_logger`
47+ static var warning_color := Color ("#ffde66" )
48+ static var success_color := Color ("#5d8c3f" )
49+ static var info_color := Color ("#70bafa" )
50+ static var hint_color := Color ("#b293fa" )
51+ static var debug_color := Color ("#d4d4d4" )
52+ static var debug_bold := true
4853
4954## This Sub-Class represents a log entry in ModLoader.
5055class ModLoaderLogEntry :
@@ -99,9 +104,15 @@ class ModLoaderLogEntry:
99104
100105 ## Get the prefix string for the log entry, including the log type and mod name.[br]
101106 ## [br]
107+ ## [b]Parameters:[/b][br]
108+ ## [param exclude_type] ([bool]): (Optional) If true, the log type (e.g., DEBUG, WARN) will be excluded from the prefix. Default is false.[br]
109+ ## [br]
102110 ## [b]Returns:[/b] [String]
103- func get_prefix () -> String :
104- return "%s %s : " % [type .to_upper (), mod_name ]
111+ func get_prefix (exclude_type : bool = false ) -> String :
112+ return "%s%s : " % [
113+ "" if exclude_type else type .to_upper () + " " ,
114+ mod_name
115+ ]
105116
106117
107118 ## Generate an MD5 hash of the log entry (prefix + message).[br]
@@ -391,6 +402,17 @@ static func get_all_entries_as_string(log_entries: Array) -> Array:
391402# Internal log functions
392403# =============================================================================
393404
405+ static func _print_rich (prefix : String , message : String , color : Color , bold := true ):
406+ if OS .has_feature ("editor" ):
407+ var prefix_text := "[b]%s [/b]" % prefix if bold else prefix
408+ print_rich ("[color=%s ]%s [/color]%s " % [
409+ color .to_html (false ),
410+ prefix_text ,
411+ message
412+ ])
413+ else :
414+ print (prefix + message )
415+
394416static func _log (message : String , mod_name : String , log_type : String = "info" , only_once := false ) -> void :
395417 if _is_mod_name_ignored (mod_name ):
396418 return
@@ -422,25 +444,32 @@ static func _log(message: String, mod_name: String, log_type: String = "info", o
422444 _write_to_log_file (JSON .stringify (get_stack (), " " ))
423445 assert (false , message )
424446 "error" :
425- printerr (log_entry .get_prefix () + message )
447+ if OS .has_feature ("editor" ):
448+ printerr (log_entry .get_prefix (true ) + message )
449+ else :
450+ printerr (log_entry .get_prefix () + message )
426451 push_error (message )
427452 _write_to_log_file (log_entry .get_entry ())
428453 "warning" :
429454 if verbosity >= VERBOSITY_LEVEL .WARNING :
430- print (log_entry .get_prefix () + message )
455+ _print_rich (log_entry .get_prefix (), message , warning_color )
431456 push_warning (message )
432457 _write_to_log_file (log_entry .get_entry ())
433- "info" , "success" :
458+ "success" :
459+ if verbosity >= VERBOSITY_LEVEL .INFO :
460+ _print_rich (log_entry .get_prefix (), message , success_color )
461+ _write_to_log_file (log_entry .get_entry ())
462+ "info" :
434463 if verbosity >= VERBOSITY_LEVEL .INFO :
435- print (log_entry .get_prefix () + message )
464+ _print_rich (log_entry .get_prefix (), message , info_color )
436465 _write_to_log_file (log_entry .get_entry ())
437466 "debug" :
438467 if verbosity >= VERBOSITY_LEVEL .DEBUG :
439- print (log_entry .get_prefix () + message )
468+ _print_rich (log_entry .get_prefix (), message , debug_color , debug_bold )
440469 _write_to_log_file (log_entry .get_entry ())
441470 "hint" :
442471 if OS .has_feature ("editor" ) and verbosity >= VERBOSITY_LEVEL .DEBUG :
443- print_rich ( "[color= %s ] %s [/color]" % [ hint_color . to_html ( false ), log_entry .get_prefix () + message ] )
472+ _print_rich ( log_entry .get_prefix (), message , hint_color )
444473
445474
446475static func _is_mod_name_ignored (mod_name : String ) -> bool :
0 commit comments