forked from Slaynash/VRCModLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Slaynash/master
update fork
- Loading branch information
Showing
7 changed files
with
92 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,68 @@ | ||
using System; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
namespace VRCModLoader | ||
{ | ||
public class VRCModLogger | ||
{ | ||
internal static bool consoleEnabled = false; | ||
private static StreamWriter log; | ||
|
||
internal static void Init() | ||
{ | ||
FileStream fileStream = null; | ||
DirectoryInfo logDirInfo = null; | ||
FileInfo logFileInfo; | ||
|
||
string logFilePath = Path.Combine(Environment.CurrentDirectory, "Logs"); | ||
logFilePath = logFilePath + "/VRCModLoader_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff") + ".log"; | ||
logFileInfo = new FileInfo(logFilePath); | ||
logDirInfo = new DirectoryInfo(logFileInfo.DirectoryName); | ||
if (!logDirInfo.Exists) logDirInfo.Create(); | ||
if (!logFileInfo.Exists) | ||
{ | ||
fileStream = logFileInfo.Create(); | ||
} | ||
else | ||
{ | ||
fileStream = new FileStream(logFilePath, FileMode.Append); | ||
} | ||
log = new StreamWriter(fileStream); | ||
log.AutoFlush = true; | ||
} | ||
|
||
internal static void Stop() | ||
{ | ||
log.Close(); | ||
} | ||
|
||
public static void Log(string s) | ||
{ | ||
if(consoleEnabled) Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] [VRCMod] " + s); | ||
Debug.Log("[VRCMod] " + s); | ||
if(log != null) log.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] " + s); | ||
} | ||
|
||
public static void Log(string s, params object[] args) | ||
{ | ||
if (consoleEnabled) Console.WriteLine("[VRCMod] " + s, args); | ||
Debug.LogFormat("[VRCMod] " + s, args); | ||
Debug.LogFormat("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] [VRCMod] " + string.Format(s, args)); | ||
if (log != null) log.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] " + string.Format(s, args)); | ||
} | ||
|
||
public static void LogError(string s) | ||
{ | ||
if (consoleEnabled) Console.WriteLine("[VRCMod] [Error] " + s); | ||
Debug.Log("[VRCMod] [Error] " + s); | ||
if (log != null) log.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] [Error] " + s); | ||
} | ||
|
||
public static void LogError(string s, params object[] args) | ||
{ | ||
if (consoleEnabled) Console.WriteLine("[VRCMod] [Error] " + s, args); | ||
Debug.LogFormat("[VRCMod] [Error] " + s, args); | ||
if (log != null) log.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] [Error] " + string.Format(s, args)); | ||
} | ||
} | ||
} |