From be83bbb64c1ff39a66675f97d0133504e81ab523 Mon Sep 17 00:00:00 2001 From: Eric Heine <erheine@nps.edu> Date: Tue, 26 Oct 2021 09:06:55 -0700 Subject: [PATCH] The EventLogController now fires an event when logging stopped with the filename of the new log file. --- Event Logger/EventLogController.cs | 16 ++++++++++------ package.json | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Event Logger/EventLogController.cs b/Event Logger/EventLogController.cs index fd8c586..c0e68b9 100644 --- a/Event Logger/EventLogController.cs +++ b/Event Logger/EventLogController.cs @@ -6,18 +6,20 @@ namespace Shared.EventLog { // A Component in charge of starting an event log and writing it to a file on completion // Depends on ScriptableVariable package public class EventLogController : MonoBehaviour { + [Header("Input Variables")] [Tooltip("The event log to write out to a file")] public EventLog eventLog; - - [Tooltip("Event to fire when logging has started")] - public GameEvent loggingStarted; - [Tooltip("The filename of the log file generated by an event log")] public StringVariable logFileName; - [Tooltip("The output directory to write the log file to")] public StringVariable outputDirectory; + [Header("Output Events")] + [Tooltip("Event to fire when logging has started")] + public GameEvent loggingStarted; + [Tooltip("Event to fire when logging has stopped, passing in the filename as the parameter")] + public StringGameEvent loggingStopped; + private DateTime startTime = DateTime.Now; private bool isLogging = false; @@ -37,10 +39,12 @@ namespace Shared.EventLog { // Add an end time event log, write the event log out to file, and clear the event log of events public void StopLogging() { if (isLogging) { - DateTime endTime = DateTime.Now; + var endTime = DateTime.Now; + var outputFilename = logFileName.Value + "." + endTime.ToString("MM-dd-yyy-HHmmss") + ".csv"; eventLog.Add("end-time", endTime.ToString("HH:mm:ss")); eventLog.WriteToFile(outputDirectory.Value, logFileName.Value + "." + endTime.ToString("MM-dd-yyy-HHmmss") + ".csv"); eventLog.Clear(); + loggingStopped?.Raise(outputFilename); isLogging = false; } } diff --git a/package.json b/package.json index bb1cf64..762d08b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.futuretech.shared", "displayName": "FutureTech Shared", "description": "Contains shared items such as the Scriptable Variables.", - "version": "0.1.28", + "version": "0.1.29", "unity": "2019.3", "license": "MIT", "repository": { -- GitLab