Skip to content
Snippets Groups Projects
Commit be83bbb6 authored by Heine, Eric R's avatar Heine, Eric R
Browse files

The EventLogController now fires an event when logging stopped with the...

The EventLogController now fires an event when logging stopped with the filename of the new log file.
parent 3e3fddb9
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......
......@@ -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": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment