Description:
Add file-based logging.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -106,6 +106,11 | |||
|
106 | 106 | #endif |
|
107 | 107 | using FNAGame g = new FNAGame(); |
|
108 | 108 | g.Run(); |
|
109 | ||
|
110 | #if !DEBUG | |
|
111 | Logging.logFile.Close(); | |
|
112 | File.Delete(Logging.logFileName); | |
|
113 | #endif | |
|
109 | 114 | } |
|
110 | 115 | |
|
111 | 116 |
@@ -1,5 +1,6 | |||
|
1 | 1 | |
|
2 | 2 | using System; |
|
3 | using System.IO; | |
|
3 | 4 | using System.Collections; |
|
4 | 5 | using System.Collections.Generic; |
|
5 | 6 | using System.Runtime.CompilerServices; |
@@ -31,6 +32,9 | |||
|
31 | 32 | // |
|
32 | 33 | |
|
33 | 34 | public static List<ITuple> entries = new List<ITuple>(); |
|
35 | public static string logFileName = string.Format("log_{0:yyyyMMdd_HHmm}.txt", DateTime.Now); | |
|
36 | ||
|
37 | public static StreamWriter logFile = File.CreateText(logFileName); | |
|
34 | 38 | private static Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> mappings = new Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> |
|
35 | 39 | { |
|
36 | 40 | {LogLevel.Critical, (ConsoleColor.White, ConsoleColor.Red)}, |
@@ -66,6 +70,9 | |||
|
66 | 70 | Console.BackgroundColor = start_background; |
|
67 | 71 | |
|
68 | 72 | Console.Out.WriteLine(string.Format(" {0} [{1}:{2}]", message, path, lineNumber)); |
|
73 | ||
|
74 | ||
|
75 | logFile.WriteLine("[{0}] {1} {0} [{1}:{2}]"); | |
|
69 | 76 | } |
|
70 | 77 | |
|
71 | 78 | private static void Log_<T>(LogLevel level, string message, T data, |
You need to be logged in to leave comments.
Login now