-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZongziTEK_Blackboard_Sticker.Helpers | ||
{ | ||
class LogHelper | ||
{ | ||
public static string LogFile = "Log.txt"; | ||
|
||
public static void NewLog(string str) | ||
{ | ||
WriteLogToFile(str, LogType.Info); | ||
} | ||
|
||
public static void NewLog(Exception ex) | ||
{ | ||
|
||
} | ||
|
||
public static void WriteLogToFile(string str, LogType logType = LogType.Info) | ||
{ | ||
string strLogType = "Info"; | ||
switch (logType) | ||
{ | ||
case LogType.Event: | ||
strLogType = "Event"; | ||
break; | ||
case LogType.Trace: | ||
strLogType = "Trace"; | ||
break; | ||
case LogType.Error: | ||
strLogType = "Error"; | ||
break; | ||
} | ||
try | ||
{ | ||
var file = MainWindow.GetDataPath() + LogFile; | ||
StreamWriter sw = new StreamWriter(file, true); | ||
sw.WriteLine(string.Format("{0} [{1}] {2}", DateTime.Now.ToString("O"), strLogType, str)); | ||
sw.Close(); | ||
} | ||
catch { } | ||
} | ||
|
||
public enum LogType | ||
{ | ||
Info, | ||
Trace, | ||
Error, | ||
Event | ||
} | ||
} | ||
} |