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 |
|
NO CONTENT: modified file, binary diff hidden |
@@ -106,6 +106,11 | |||||
|
106 | #endif |
|
106 | #endif |
|
107 | using FNAGame g = new FNAGame(); |
|
107 | using FNAGame g = new FNAGame(); |
|
108 | g.Run(); |
|
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 | using System; |
|
2 | using System; |
|
|
3 | using System.IO; | ||
|
3 | using System.Collections; |
|
4 | using System.Collections; |
|
4 | using System.Collections.Generic; |
|
5 | using System.Collections.Generic; |
|
5 | using System.Runtime.CompilerServices; |
|
6 | using System.Runtime.CompilerServices; |
@@ -31,6 +32,9 | |||||
|
31 | // |
|
32 | // |
|
32 |
|
33 | ||
|
33 | public static List<ITuple> entries = new List<ITuple>(); |
|
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 | private static Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> mappings = new Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> |
|
38 | private static Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> mappings = new Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> |
|
35 | { |
|
39 | { |
|
36 | {LogLevel.Critical, (ConsoleColor.White, ConsoleColor.Red)}, |
|
40 | {LogLevel.Critical, (ConsoleColor.White, ConsoleColor.Red)}, |
@@ -66,6 +70,9 | |||||
|
66 | Console.BackgroundColor = start_background; |
|
70 | Console.BackgroundColor = start_background; |
|
67 |
|
71 | ||
|
68 | Console.Out.WriteLine(string.Format(" {0} [{1}:{2}]", message, path, lineNumber)); |
|
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 | private static void Log_<T>(LogLevel level, string message, T data, |
|
78 | private static void Log_<T>(LogLevel level, string message, T data, |
You need to be logged in to leave comments.
Login now