Skip to content

Commit

Permalink
Add crash logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycast committed Dec 23, 2024
1 parent d297d9b commit 37e4184
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 38 deletions.
35 changes: 13 additions & 22 deletions src/GlobalVariables.as
Original file line number Diff line number Diff line change
Expand Up @@ -659,31 +659,22 @@ package
Screenshots.saveToClipboard(gameMain);
}

public function logDebugError(id:String, params:Object = null):void
public function logDebugError(error_message:String):void
{
var output:String = id;
if (params is Error)
CONFIG::release
{
var err:Error = (params as Error);
output += "\n" + err.name + "\n" + err.message + "\n" + err.errorID + "\n" + err.getStackTrace();
var _debugLoader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest(URLs.resolve(URLs.CRASH_LOG_URL));
var requestVars:URLVariables = new URLVariables();
Constant.addDefaultRequestVariables(requestVars);
requestVars.session = userSession;
requestVars.error = error_message;
requestVars.settings = Capabilities.serverString;
req.data = requestVars;
req.method = URLRequestMethod.POST;
_debugLoader.dataFormat = URLLoaderDataFormat.TEXT;
_debugLoader.load(req);
}
else
{
output += "\n" + params;
}

var _debugLoader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest(URLs.resolve(URLs.DEBUG_LOG_URL));
var requestVars:URLVariables = new URLVariables();
Constant.addDefaultRequestVariables(requestVars);
requestVars.session = userSession;
requestVars.error = output;
requestVars.gameVersion = CONFIG::timeStamp;
requestVars.gameSettings = Capabilities.serverString;
req.data = requestVars;
req.method = URLRequestMethod.POST;
_debugLoader.dataFormat = URLLoaderDataFormat.TEXT;
_debugLoader.load(req);
}

//- Full Screen
Expand Down
27 changes: 12 additions & 15 deletions src/Logger.as
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,7 @@ package
history.unshift();

// Create Log Message
var msg:String = "";
if (text is Error)
{
var err:Error = (text as Error);
msg = "Error: " + exception_error(err);
}
else if (text is ErrorEvent)
{
var erre:ErrorEvent = (text as ErrorEvent);
msg = "Error: " + event_error(erre);
}
else
{
msg = text;
}
var msg:String = generate_message(text);

msg = ((!simple ? "[" + TimeUtil.convertToHHMMSS(currentTime / 1000) + "][" + class_name(clazz) + "] " : "") + msg);

Expand Down Expand Up @@ -175,6 +161,17 @@ package
}
}

public static function generate_message(text:*):String
{
if (text is Error)
return "Error: " + exception_error(text as Error);

else if (text is ErrorEvent)
return "Error: " + event_error(text as ErrorEvent);

return text;
}

public static function exception_error(err:Error):String
{
return "(" + err.errorID + ") " + err.name + "\n" + err.message + "\n" + err.getStackTrace();
Expand Down
1 change: 1 addition & 0 deletions src/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ package
Logger.error("UNCAUGHT_ERROR", e.error);
Logger.info("INFO", "If possible, please submit this crash to the developers.");
Alert.add("A fatal error has occured. You should restart the game.", 7200, Alert.RED);
_gvars.logDebugError(Logger.generate_message(e.error));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/URLs.as
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ package
public static var SITE_HISCORES_URL:String = "game/r3/r3-hiscores.php";
public static var SITE_REPLAYS_URL:String = "game/r3/r3-replays.php";
public static var LEVEL_STATS_URL:String = "levelstats.php?level=";
public static var DEBUG_LOG_URL:String = "game/r3/r3-debugLog.php";
public static var CRASH_LOG_URL:String = "game/r3/r3-crashLog.php";

// Song & Gameplay URLs
public static var SONG_DATA_URL:String = "game/r3/r3-songLoad.php";
Expand Down

0 comments on commit 37e4184

Please sign in to comment.