using StgSharp.Geometries; using StgSharp.Graphics; using System; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace StgSharp { internal enum LogType { Error, Warning, Info, InfoError, InfoWarning, } internal static unsafe partial class InternalIO { internal const string SSGC_libname = "StgSharpGraphic"; internal const string SSG_errorlog = "SSG_errorlog.log"; static InternalIO() { GLtype.Add(typeof(float), GLconst.FLOAT); GLtype.Add(typeof(int), GLconst.INT); GLtype.Add(typeof(uint), GLconst.UNSIGNED_INT); GLtype.Add(typeof(short), GLconst.SHORT); GLtype.Add(typeof(ushort), GLconst.UNSIGNED_SHORT); GLtype.Add(typeof(sbyte), GLconst.BYTE); GLtype.Add(typeof(byte), GLconst.UNSIGNED_BYTE); } internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType) { if (!File.Exists(InternalIO.SSG_errorlog)) { FileStream stream = File.Create(InternalIO.SSG_errorlog); stream.Close(); } using (StreamWriter logStream = File.AppendText(SSG_errorlog)) { logStream.WriteLine(beforeTime); logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}"); logStream.WriteLine(logLine); } } internal static void InternalWriteLog(string logLine, LogType logType) { if (!File.Exists(InternalIO.SSG_errorlog)) { FileStream stream = File.Create(InternalIO.SSG_errorlog); stream.Close(); } using (StreamWriter logStream = File.AppendText(SSG_errorlog)) { logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}"); logStream.WriteLine(logLine); } } internal static void InternalAppendLog(string log) { if (!File.Exists(InternalIO.SSG_errorlog)) { FileStream stream = File.Create(InternalIO.SSG_errorlog); stream.Close(); } using (StreamWriter logStream = File.AppendText(SSG_errorlog)) { logStream.WriteLine(log); } } } }