Repository navigation
Expand file tree
/
Copy pathLogger.cs
More file actions
90 lines (85 loc) · 3.36 KB
/
Copy pathLogger.cs
File metadata and controls
90 lines (85 loc) · 3.36 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using UnityEngine;
using System.IO;
public class Logger : MonoBehaviour
{
string file = $"C:\\Users\\{Environment.UserName}\\Documents\\FireFall Games\\Key Blaster\\kb_log.txt";
private void Start()
{
BeginLog();
}
public void BeginLog()
{
//If folder doesn't exist in Docs, create...
if (!Directory.Exists($"C:\\Users\\{Environment.UserName}\\Documents\\FireFall Games")) {
Directory.CreateDirectory($"C:\\Users\\{Environment.UserName}\\Documents\\FireFall Games");
Directory.CreateDirectory($"C:\\Users\\{Environment.UserName}\\Documents\\FireFall Games\\Key Blaster");
}
//If log file doesn't exist in Docs, create...
if (!File.Exists(file))
{
using (StreamWriter sw = File.CreateText(file))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine("Creating log file...");
sw.WriteLine("**************************************************");
}
}
}
public void WriteToLog(string logMessage)
{
using (StreamWriter sw = File.CreateText(file))
{
sw.WriteLine(DateTime.Now);
sw.WriteLine($"{logMessage}");
sw.WriteLine("**************************************************");
}
}
public void WriteToConsole(string optionalMessage = "", int optionalInt = -400, float optionalFloat = -400)
{
if (optionalInt == 0 && optionalFloat == 0)
{
Debug.Log(optionalMessage);
}
if (optionalMessage != "" && optionalInt != -400 && optionalFloat != -400)
{
Debug.Log("**************************************************");
Debug.Log(optionalMessage + " -MESSAGE");
Debug.Log(optionalInt + " -INT");
Debug.Log(optionalFloat + " -FLOAT");
Debug.Log("**************************************************");
}
if (optionalMessage != "")
{
Debug.Log("**************************************************");
Debug.Log(optionalMessage + " -MESSAGE");
Debug.Log("**************************************************");
}
if (optionalInt != -400)
{
Debug.Log("**************************************************");
Debug.Log(optionalInt + " -INT");
Debug.Log("**************************************************");
}
if (optionalFloat != -400)
{
Debug.Log("**************************************************");
Debug.Log(optionalFloat + " -FLOAT");
Debug.Log("**************************************************");
}
if (optionalMessage != "" && optionalInt != -400)
{
Debug.Log("**************************************************");
Debug.Log(optionalMessage + " -MESSAGE");
Debug.Log(optionalInt + " -INT");
Debug.Log("**************************************************");
}
if (optionalMessage != "" && optionalFloat != -400)
{
Debug.Log("**************************************************");
Debug.Log(optionalMessage + " -MESSAGE");
Debug.Log(optionalFloat + " -FLOAT");
Debug.Log("**************************************************");
}
}
}