Created
February 27, 2015 19:58
-
-
Save sowamazing/83987f57fcd8eba8a558 to your computer and use it in GitHub Desktop.
Logging Debug Output: Sending Debug.Log() Output to Loggly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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