Skip to content

Commit 0c6dfa4

Browse files
authored
Fixed #179 RuntimeLoggingService behavior (#180)
1 parent 8e100e1 commit 0c6dfa4

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed
Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Windows.Forms;
2-
3-
namespace NotepadSharp.Core.Logging
1+
namespace NotepadSharp.Core.Logging
42
{
53
/// <summary>
64
/// This class is the logger service for runtime usage.
@@ -9,19 +7,48 @@ namespace NotepadSharp.Core.Logging
97
/// </summary>
108
public class RuntimeLoggerService : ILoggingService
119
{
10+
/// <summary>
11+
/// Writes error message to log file.
12+
/// </summary>
13+
/// <param name="message"></param>
1214
public void Error(string message)
1315
{
14-
MessageBox.Show(message, "Error");
16+
Write("Error", message);
1517
}
1618

19+
/// <summary>
20+
/// Writes informational message to log file.
21+
/// </summary>
22+
/// <param name="message"></param>
1723
public void Info(string message)
1824
{
19-
MessageBox.Show(message, "Info");
25+
Write("Info", message);
2026
}
2127

28+
/// <summary>
29+
/// Writes warning message to log file.
30+
/// </summary>
31+
/// <param name="message"></param>
2232
public void Warn(string message)
2333
{
24-
MessageBox.Show(message, "Warning");
34+
Write("Warning", message);
35+
}
36+
37+
private static void Write(string type, string message)
38+
{
39+
string _path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
40+
41+
try
42+
{
43+
using (System.IO.StreamWriter streamWriter = System.IO.File.AppendText(System.IO.Path.Combine(_path, "Log.txt")))
44+
{
45+
streamWriter.WriteLine($"{System.DateTime.Now.ToLongTimeString()} {System.DateTime.Now.ToLongDateString()} [{type}]: {message}");
46+
}
47+
}
48+
catch (System.Exception ex)
49+
{
50+
System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error");
51+
}
2552
}
2653
}
2754
}

Notepad-Sharp/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Changes>
33
<body>
44
<release date="${buildTimestamp}" description="" version="2.0.0">
5+
<action dev="Zachary Pedigo" issue="179" date="04-23-2025" type="fix">Replaced MessageBox runtime logging with output log.</action>
56
<action dev="Zachary Pedigo" issue="142" date="03-03-2025" type="add">Added frontend microservices architecture for logging.</action>
67
<action dev="Zachary Pedigo" issue="118" date="01-15-2025" type="add">Added native support for Assembly language.</action>
78
<action dev="Zachary Pedigo" issue="164" date="01-13-2025" type="fix">Added missing C# preprocessor directives.</action>

0 commit comments

Comments
 (0)