Posted
By Immoon
So I Was Bored And Saw In Exo's A Class Called Logger Basically Gets Logs And Logs It To A File Providing Better Details To Possibly Help Support Staff Etc So I Took This Idea And Remade In Nihon Just Making It Better Overall And Better Performing So I'm Releasing It Here Since I Gave To Minish And Can't Expect It Not To Be Shared So Here It Is Ofc I'm Not Gonna Post The Really Good One I Wrote This Will Be A Watered Down Version That Works Well If You Use Credit OwO
Steps
1. Make A Class Call It FileLogger Or Whatever The F You Wanna Call It
2. Paste The Code Below Fix Errors Add Needed Using Statements And Just Fix Errors
Heres A Example Of Usage
private void WindowLoaded(object sender, RoutedEventArgs e)
{
Exception Ex = new Exception();
Ex.Throw();
Logger.Log(Ex.ToString(), FileLogger.LogTypes.Error);
}
Btw This May Be Written Wrong WeAreDevs Has No Syntax So Idk
public class FileLogger
{
public enum LogTypes
{
Error,
Warn,
Success
};
public static string CurrentFileName = DateTime.Now.ToShortTimeString() + ".txt";
public static string GetLastCreatedLog() { return Directory.GetCurrentDirectory() + "\\System Logs\\" + CurrentFileName; }
public static void Log(string Text, LogTypes LogType)
{
string FilePath = Directory.GetCurrentDirectory() + "\\System Logs\\" + CurrentFileName.Replace(":", "-");
string Message = "[" + DateTime.UtcNow.ToLocalTime().ToString() + "] : " + Text;
try
{
if (!File.Exists(FilePath))
{
using (StreamWriter StreamWriter = new(FilePath))
{
StreamWriter.WriteLine(Message);
StreamWriter.Close();
}
}
if (LogType == LogTypes.Error)
{
/* If Error Show Msg Box Or Some Thing */
}
}
catch (Exception Ex)
{
Logger.Log(Ex.ToString(), LogTypes.Error);
}
}
}
Credit Me You Skid :Gun: Or I Will Find You
Replied
Vouch for Immune
😳
https://media.discordapp.net/attachments/769721958426083333/866511170201714768/image.png
Cancel
Post
Replied
prolly not gonna use this but vouch for zaddy immoon
Cancel
Post
"r u alce" - pleb8000
"lets make stuff" - Immoon
https://cdn.discordapp.com/attachments/850904515858923590/921759578620825640/VortexAllias.png
Replied
libs.logger.Log("hehe boi");
vouch for improving my code :blush:
VOUCH
Cancel
Post
hi123
Replied
Vouch cool beans
Cancel
Post
https://cdn.discordapp.com/attachments/901227777741692968/991219346124853278/sJkFFl5.png
we love security breaches
Replied
cool great cool cool awesome great cool great
Cancel
Post
Replied
vouch I was aboosed https://cdn.discordapp.com/attachments/857477564402368525/866518626075672606/unknown.png
Cancel
Post
Discord : Doctor Doom#0550
Replied
vouch
Content length must be 69-420 chars
Cancel
Post
use. dark. mode.
Replied
Exception.Message
This Exists, However, if you want a full StackTrace then don't mind me lol
Cancel
Post
Replied
vouch /charrrsssssss
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post