-
Notifications
You must be signed in to change notification settings - Fork 31
ModLoaderLog
Extends: Node
This Class provides methods for logging, retrieving logged data, and internal methods for working with log files.
Method | Description |
---|---|
fatal |
Logs the error in red and a stack trace. Prefixed FATAL-ERROR. Note: Stops the execution in editor |
error |
Logs the message and pushes an error. Prefixed ERROR. |
warning |
Logs the message and pushes a warning. Prefixed WARNING. |
info |
Logs the message. Prefixed INFO. Most mods will use this. |
success |
Logs the message. Prefixed SUCCESS. |
debug |
Logs the message. Prefixed DEBUG. |
debug_json_print |
Logs the message formatted with [method JSON.print]. Prefixed DEBUG. |
Method | Description |
---|---|
get_all_as_resource |
Returns an array of log entries as a resource. |
get_all_as_string |
Returns an array of log entries as a resource. |
get_by_mod_as_resource |
Returns an array of log entries as a resource for a specific mod_name. |
get_by_mod_as_string |
Returns an array of log entries as a string for a specific mod_name. |
get_by_type_as_resource |
Returns an array of log entries as a resource for a specific type. |
get_by_type_as_string |
Returns an array of log entries as a string for a specific type. |
get_all |
Returns an array of all log entries. |
get_by_mod |
Returns an array of log entries for a specific mod_name. |
get_by_type |
Returns an array of log entries for a specific type. |
get_all_entries_as_string |
Returns an array of log entries represented as strings. |
func fatal(message: String, mod_name: String, only_once: bool = false) -> void
Logs the error in red and a stack trace. Prefixed FATAL-ERROR.
Note: Stops the execution in editor
Parameters:
- message (String): The message to be logged as an error.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func error(message: String, mod_name: String, only_once: bool = false) -> void
Logs the message and pushes an error. Prefixed ERROR.
Note: Always logged
Parameters:
- message (String): The message to be logged as an error.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func warning(message: String, mod_name: String, only_once: bool = false) -> void
Logs the message and pushes a warning. Prefixed WARNING.
Note: Logged with verbosity level at or above warning (-v).
Parameters:
- message (String): The message to be logged as a warning.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func info(message: String, mod_name: String, only_once: bool = false) -> void
Logs the message. Prefixed INFO.
Note: Logged with verbosity level at or above info (-vv).
Parameters:
- message (String): The message to be logged as an information.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func success(message: String, mod_name: String, only_once: bool = false) -> void
Logs the message. Prefixed SUCCESS.
Note: Logged with verbosity level at or above info (-vv).
Parameters:
- message (String): The message to be logged as a success.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func debug(message: String, mod_name: String, only_once: bool = false) -> void
Logs the message. Prefixed DEBUG.
Note: Logged with verbosity level at or above debug (-vvv).
Parameters:
- message (String): The message to be logged as a debug.
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func debug_json_print(message: String, json_printable, mod_name: String, only_once: bool = false) -> void
Logs the message formatted with [method JSON.print]. Prefixed DEBUG.
Note: Logged with verbosity level at or above debug (-vvv).
Parameters:
- message (String): The message to be logged as a debug.
- json_printable (Variant): The variable to be formatted and printed using [method JSON.print].
- mod_name (String): The name of the mod or ModLoader class associated with this log entry.
- only_once (bool): (Optional) If true, the log entry will only be logged once, even if called multiple times. Default is false.
Returns: void
func get_all_as_resource() -> Array
Returns an array of log entries as a resource.
Returns:
- Array: An array of log entries represented as resource.
func get_all_as_string() -> Array
Returns an array of log entries as a string.
Returns:
- Array: An array of log entries represented as strings.
func get_by_mod_as_resource(mod_name: String) -> Array
Returns an array of log entries as a resource for a specific mod_name.
Parameters:
- mod_name (String): The name of the mod or ModLoader class associated with the log entries.
Returns:
- Array: An array of log entries represented as resource for the specified mod_name.
func get_by_mod_as_string(mod_name: String) -> Array
Returns an array of log entries as a string for a specific mod_name.
Parameters:
- mod_name (String): The name of the mod or ModLoader class associated with the log entries.
Returns:
- Array: An array of log entries represented as strings for the specified mod_name.
func get_by_type_as_resource(type: String) -> Array
Returns an array of log entries as a resource for a specific type.
Parameters:
- type (String): The log type associated with the log entries.
Returns:
- Array: An array of log entries represented as resource for the specified type.
func get_by_type_as_string(type: String) -> Array
Returns an array of log entries as a string for a specific type.
Parameters:
- type (String): The log type associated with the log entries.
Returns:
- Array: An array of log entries represented as strings for the specified type.
func get_all() -> Array
Returns an array of all log entries.
Returns:
- Array: An array of all log entries.
func get_by_mod(mod_name: String) -> Array
Returns an array of log entries for a specific mod_name.
Parameters:
- mod_name (String): The name of the mod or ModLoader class associated with the log entries.
Returns:
- Array: An array of log entries for the specified mod_name.
func get_by_type(type: String) -> Array
Returns an array of log entries for a specific type.
Parameters:
- type (String): The log type associated with the log entries.
Returns:
- Array: An array of log entries for the specified type.
func get_all_entries_as_string(log_entries: Array) -> Array
Returns an array of log entries represented as strings.
Parameters:
- log_entries (Array): An array of ModLoaderLogEntry Objects.
Returns:
- Array: An array of log entries represented as strings.
var mod_name: String
Name of the mod or ModLoader class this entry refers to.
var message: String
The message of the log entry.
var type: String
The log type, which indicates the verbosity level of this entry.
var time: String
The readable format of the time when this log entry was created. Used for printing in the log file and output.
var time_stamp: int
The timestamp when this log entry was created. Used for comparing and sorting log entries by time.
var stack: Array
An array of ModLoaderLogEntry objects. If the message has been logged before, it is added to the stack.
func _init(_mod_name: String, _message: String, _type: String, _time: String) -> void
Initialize a ModLoaderLogEntry object with provided values.
Parameters:
- _mod_name (String): Name of the mod or ModLoader class this entry refers to.
- _message (String): The message of the log entry.
- _type (String): The log type, which indicates the verbosity level of this entry.
- _time (String): The readable format of the time when this log entry was created.
Returns: void
func get_entry() -> String
Get the log entry as a formatted string.
Returns: String
func get_prefix() -> String
Get the prefix string for the log entry, including the log type and mod name.
Returns: String
func get_md5() -> String
Generate an MD5 hash of the log entry (prefix + message).
Returns: String
func get_all_entries() -> Array
Get all log entries, including the current entry and entries in the stack.
Returns: Array
func time(a: ModLoaderLogEntry, b: ModLoaderLogEntry) -> bool
Custom sorter that orders logs by time
const VERBOSITY_LEVEL: Dictionary = {"DEBUG":3,"ERROR":0,"INFO":2,"WARNING":1}
const LOG_NAME: String = "ModLoader:Log"
const MOD_LOG_PATH: String = "user://logs/modloader.log"
Path to the latest log file.
Home ~ Setup ~ Mod Structure ~ Mod Files ~ API Methods ~ Logging