Add loglevel to logger and change DateTime to UtcNow
This commit is contained in:
@@ -6,22 +6,24 @@ namespace AndroidSideloader
|
||||
internal class Logger
|
||||
{
|
||||
public string logfile = Properties.Settings.Default.CurrentLogPath;
|
||||
public static bool Log(string text, bool ret = true)
|
||||
public static bool Log(string text, string logLevel = "NOTICE", bool ret = true)
|
||||
{
|
||||
|
||||
string time = DateTime.Now.ToString("hh:mmtt(UTC): ");
|
||||
if (text.Length > 5)
|
||||
{
|
||||
|
||||
string newline = "\n";
|
||||
if (text.Length > 40 && text.Contains("\n"))
|
||||
{
|
||||
newline += "\n\n";
|
||||
}
|
||||
|
||||
try { File.AppendAllText(Properties.Settings.Default.CurrentLogPath, time + text + newline); } catch { }
|
||||
if (text.Length <= 5)
|
||||
return ret;
|
||||
|
||||
string time = DateTime.UtcNow.ToString("hh:mmtt(UTC): ");
|
||||
string newline = text.Length > 40 && text.Contains("\n") ? "\n\n" : "\n";
|
||||
string logEntry = time + "[" + logLevel.ToUpper() + "] " + text + newline;
|
||||
|
||||
try
|
||||
{
|
||||
File.AppendAllText(Properties.Settings.Default.CurrentLogPath, logEntry);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Handle the exception if necessary
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user