-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogger.cs
28 lines (22 loc) · 858 Bytes
/
Logger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class Logger : MonoBehaviour {
private string logFilePath = "A:\\Home\\Game Related\\Stardew Valley Related\\SV Planner App/log.txt";
void Awake() {
// Subscribe to the log message received event
Application.logMessageReceived += HandleLog;
}
void OnDestroy() {
// Unsubscribe from the log message received event
Application.logMessageReceived -= HandleLog;
}
void HandleLog(string logString, string stackTrace, LogType type) {
// Format the log message
string logMessage = $"{System.DateTime.Now}: {type} - {logString}\n{stackTrace}\n";
// Debug.Log(logMessage);
// Write the log message to the file
File.AppendAllText(logFilePath, logMessage);
}
}