Skip to content

Instantly share code, notes, and snippets.

@WikkidEdd
Created August 27, 2018 10:43
Show Gist options
  • Save WikkidEdd/c74c6b3a6af249f6057b63c48846dbdc to your computer and use it in GitHub Desktop.
Save WikkidEdd/c74c6b3a6af249f6057b63c48846dbdc to your computer and use it in GitHub Desktop.
Unity script to output to native UWP logs which can then be access via the device portal. Piggy backs on the Microsoft-Windows-Diagnostics-LoggingChannel provider as per this blog post https://blogs.windows.com/buildingapps/2016/06/10/using-device-portal-to-view-debug-logs-for-uwp/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if NETFX_CORE
using Windows.Foundation.Diagnostics;
#endif
public class UWPLogs : MonoBehaviour {
#if NETFX_CORE
LoggingChannel loggingChannel;
private void Awake()
{
Application.logMessageReceived += HandleLog;
loggingChannel = new LoggingChannel(Application.productName, null, new Guid("4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a"));
loggingChannel.LogMessage("UWP Logging Started");
}
private void HandleLog(string logOutput, string stackTrace, LogType type)
{
loggingChannel.LogMessage(type.ToString() + ": " + logOutput);
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment