the initial commit to the repo.

This commit is contained in:
NukedBart 2025-10-25 01:27:14 +08:00
parent 025c032b8c
commit 1b757591b9
264 changed files with 21882 additions and 0 deletions

51
stoopid.raw/Logger.cs Normal file
View file

@ -0,0 +1,51 @@
using System;
using System.IO;
using UnityEngine;
public static class Logger
{
public enum LogLevel
{
Info,
Warning,
Error
}
private static readonly string logFilePath = Path.Combine(Application.persistentDataPath, "log3.txt");
public static void Log(string message, LogLevel level = LogLevel.Info)
{
try
{
WriteLogToFile(FormatLogMessage(message, level));
}
catch (Exception ex)
{
Debug.LogError("Failed to log message: " + ex.Message);
}
}
private static string FormatLogMessage(string message, LogLevel level)
{
string arg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
return $"{arg} [{level}] {message}";
}
private static void WriteLogToFile(string message)
{
using StreamWriter streamWriter = new StreamWriter(logFilePath, append: true);
streamWriter.WriteLine(message);
}
public static void ClearLog()
{
try
{
File.Delete(logFilePath);
}
catch (Exception ex)
{
Debug.LogError("Failed to clear log file: " + ex.Message);
}
}
}