Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/mod_loader/api/deprecated.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ static func _deprecated_log(msg: String) -> void:
ModLoaderLog.warning(msg, LOG_NAME)
else:
ModLoaderLog.fatal(msg, LOG_NAME)
ModLoaderLog.debugLine()
26 changes: 26 additions & 0 deletions addons/mod_loader/api/log.gd
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,32 @@ static func _clear_old_log_backups() -> void:
dir.remove(file_to_delete)



# Debugging function
# =============================================================================

# Logs the source location and code line
# parameters:
# - Optionaltext
# - depth (stack item, -1 is default set to last item)
static func debugLine(optionaltext:String = "Problem File", depth:int = -1) -> void:
var frame = get_stack()

# Condition to -1 to take last stach element and prevent from
# inputing negative numbers
if depth<0: #Get the top stack
depth = frame.size()-1

# To prevent function from crashing if depth to high
if depth > frame.size()-1:
depth = frame.size()-1

var line = "Line:" + str(frame[depth]["line"])
var source = "Source:" + frame[depth]["source"]
var function = "Function:" + frame[depth]["function"]
print("%s - %s - %s - %s" % [optionaltext,source,function,line])


# Internal util funcs
# =============================================================================
# This are duplicates of the functions in mod_loader_utils.gd to prevent
Expand Down