Skip to content

Instantly share code, notes, and snippets.

@sowamazing
Created February 27, 2015 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sowamazing/83987f57fcd8eba8a558 to your computer and use it in GitHub Desktop.
Save sowamazing/83987f57fcd8eba8a558 to your computer and use it in GitHub Desktop.
Logging Debug Output: Sending Debug.Log() Output to Loggly
public class LogOutputHandler : MonoBehaviour {
//Register the HandleLog function on scene start to fire on debug.log events
void Awake(){
Application.RegisterLogCallback(HandleLog);
}
//Create a string to store log level in
string level = "";
//Capture debug.log output, send logs to Loggly
public void HandleLog(string logString, string stackTrace, LogType type) {
//Initialize WWWForm and store log level as a string
level = type.ToString ();
var loggingForm = new WWWForm();
//Add log message to WWWForm
loggingForm.AddField("LEVEL", level);
loggingForm.AddField("Message", logString);
loggingForm.AddField("Stack_Trace", stackTrace);
//Add any Game or Device MetaData that would be useful to finding issues later
loggingForm.AddField("Device_Model", SystemInfo.deviceModel);
//Send WWW Form to Loggly
var sendLog = new WWW("http://logs-01.loggly.com/inputs/TOKEN/tag/http/", loggingForm);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment