Added Base Project

This commit is contained in:
Müller Wayan
2025-02-23 14:29:32 +01:00
parent cda7948be9
commit a6130d4ff0
364 changed files with 12117 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Firebird2D.Logger
{
public enum LogType
{
Info,
Warning,
Error
}
public static class GameLogger
{
private static readonly string LogFilePath = "Logs/Log.txt";
public static bool logActive { get { return _logActive; } set { _logActive = value; if (value == false) Log("Logger", LogType.Info, "Log Deactivated"); } }
private static bool _logActive = true;
public static void Initalize()
{
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
using (FileStream fileStream = File.Open(LogFilePath, FileMode.OpenOrCreate | FileMode.Append))
{
AddText(fileStream, "===================" + System.DateTime.Today.ToString("dd,MM,yy") + "===================");
}
}
}
public static void Log(string loggingInstance, LogType type, string message)
{
if (_logActive)
{
using (FileStream fileStream = File.Open(LogFilePath, FileMode.OpenOrCreate | FileMode.Append))
{
AddText(fileStream, type.ToString("g") + ": " + loggingInstance + " -> " + message);
fileStream.Close();
}
}
}
private static void AddText(FileStream fs, string value)
{
byte[] info = new UTF8Encoding(true).GetBytes(value);
fs.Write(info, 0, info.Length);
}
}
}