Fixes? and side channels.
This commit is contained in:
@ -1,19 +1,29 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using Unity.MLAgents.SideChannels;
|
||||
using UnityEngine;
|
||||
|
||||
public class Logger
|
||||
namespace Statistics
|
||||
{
|
||||
private const string Directory = "/Logs/";
|
||||
private const string BaseName = "Log#";
|
||||
|
||||
public static void SaveLog<T>(T objToSerialize)
|
||||
public class LoggerSideChannel : SideChannel
|
||||
{
|
||||
var dir = Application.persistentDataPath + Directory;
|
||||
if (!System.IO.Directory.Exists(dir))
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
public LoggerSideChannel()
|
||||
{
|
||||
ChannelId = new Guid("621f0a70-4f87-11ea-a6bf-784f4387d1f7");
|
||||
}
|
||||
|
||||
var logName = BaseName + (System.IO.Directory.GetFiles(dir).Length + 1).ToString();
|
||||
var json = JsonUtility.ToJson(objToSerialize);
|
||||
File.WriteAllText(dir + logName, json);
|
||||
public void SendLog(Log log)
|
||||
{
|
||||
using (var logOut = new OutgoingMessage())
|
||||
{
|
||||
logOut.WriteString(JsonUtility.ToJson(log));
|
||||
QueueMessageToSend(logOut);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMessageReceived(IncomingMessage msg)
|
||||
{
|
||||
var receivedString = msg.ReadString();
|
||||
Debug.Log("From Python : " + receivedString);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user