Skip to content

Commit 4deac14

Browse files
committed
* See previous commit. Visual studio being silly
1 parent 770e06e commit 4deac14

File tree

5 files changed

+46
-27
lines changed

5 files changed

+46
-27
lines changed

MemPlus/Classes/LOG/Log.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,39 @@
22

33
namespace MemPlus.Classes.LOG
44
{
5-
internal class Log
5+
public abstract class Log : ILogMethods
66
{
7-
private readonly DateTime _time;
8-
private readonly string _value;
7+
/// <summary>
8+
/// The type of log
9+
/// </summary>
10+
internal LogType LogType { get; set; }
911

10-
internal Log(string data)
12+
protected DateTime Time;
13+
protected string Data;
14+
15+
public DateTime GetDate()
1116
{
12-
_time = DateTime.Now;
13-
_value = data;
17+
return Time;
1418
}
1519

16-
internal DateTime GetDate()
20+
public void AddData(string data)
1721
{
18-
return _time;
22+
Time = DateTime.Now;
23+
Data = data;
1924
}
2025

21-
internal string GetValue()
26+
public string GetData()
2227
{
23-
return _value;
28+
return Data;
2429
}
2530
}
31+
32+
/// <summary>
33+
/// An enumeration of all available log types
34+
/// </summary>
35+
public enum LogType
36+
{
37+
Application,
38+
Ram
39+
}
2640
}

MemPlus/Classes/RAM/RamController.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal sealed class RamController
2929
internal RamController(Dispatcher dispatcher, SfCircularGauge gauge, Label lblTotal, Label lblAvailable, int timerInterval, LogController logController)
3030
{
3131
_logController = logController ?? throw new ArgumentNullException(nameof(logController));
32-
_logController.AddLog(new Log("Initializing RamController"));
32+
_logController.AddLog(new ApplicationLog("Initializing RamController"));
3333

3434
if (timerInterval <= 0) throw new ArgumentException("Timer interval cannot be less than or equal to zero!");
3535

@@ -46,26 +46,26 @@ internal RamController(Dispatcher dispatcher, SfCircularGauge gauge, Label lblTo
4646
_ramTimer.Elapsed += OnTimedEvent;
4747
_ramTimer.Interval = timerInterval;
4848

49-
_logController.AddLog(new Log("Done initializing RamController"));
49+
_logController.AddLog(new ApplicationLog("Done initializing RamController"));
5050
}
5151

5252
internal void EnableMonitor()
5353
{
5454
if (_ramTimer.Enabled) return;
5555
_ramTimer.Enabled = true;
5656
OnTimedEvent(null, null);
57-
_logController.AddLog(new Log("The RAM monitor has been enabled"));
57+
_logController.AddLog(new ApplicationLog("The RAM monitor has been enabled"));
5858
}
5959

6060
internal void DisableMonitor()
6161
{
6262
_ramTimer.Enabled = false;
63-
_logController.AddLog(new Log("The RAM monitor has been disabled"));
63+
_logController.AddLog(new ApplicationLog("The RAM monitor has been disabled"));
6464
}
6565

6666
private void OnTimedEvent(object source, ElapsedEventArgs e)
6767
{
68-
_logController.AddLog(new Log("RAM monitor timer has been called"));
68+
_logController.AddLog(new ApplicationLog("RAM monitor timer has been called"));
6969

7070
UpdateRamUsage();
7171

@@ -77,12 +77,12 @@ private void OnTimedEvent(object source, ElapsedEventArgs e)
7777
_lblAvailable.Content = (RamUsage / 1024 / 1024 / 1024).ToString("F2") + " GB";
7878
});
7979

80-
_logController.AddLog(new Log("Finished RAM monitor timer"));
80+
_logController.AddLog(new ApplicationLog("Finished RAM monitor timer"));
8181
}
8282

8383
internal async Task ClearMemory(bool filesystemcache)
8484
{
85-
_logController.AddLog(new Log("Clearing RAM memory"));
85+
_logController.AddLog(new ApplicationLog("Clearing RAM memory"));
8686

8787
await Task.Run(async () =>
8888
{
@@ -103,12 +103,12 @@ await Task.Run(async () =>
103103
RamSavings = oldUsage - newUsage;
104104
});
105105

106-
_logController.AddLog(new Log("Done clearing RAM memory"));
106+
_logController.AddLog(new ApplicationLog("Done clearing RAM memory"));
107107
}
108108

109109
private void UpdateRamUsage()
110110
{
111-
_logController.AddLog(new Log("Updating RAM usage"));
111+
_logController.AddLog(new ApplicationLog("Updating RAM usage"));
112112

113113
double total = Convert.ToDouble(_info.TotalPhysicalMemory);
114114
double usage = total - Convert.ToDouble(_info.AvailablePhysicalMemory);
@@ -118,7 +118,7 @@ private void UpdateRamUsage()
118118
RamUsagePercentage = perc;
119119
RamTotal = total;
120120

121-
_logController.AddLog(new Log("Finished updating RAM usage"));
121+
_logController.AddLog(new ApplicationLog("Finished updating RAM usage"));
122122
}
123123
}
124124
}

MemPlus/MemPlus.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
<DependentUpon>App.xaml</DependentUpon>
7070
<SubType>Code</SubType>
7171
</Compile>
72+
<Compile Include="Classes\LOG\ApplicationLog.cs" />
73+
<Compile Include="Classes\LOG\ILogMethods.cs" />
7274
<Compile Include="Classes\LOG\Log.cs" />
7375
<Compile Include="Classes\LOG\LogController.cs" />
7476
<Compile Include="Classes\RAM\RamController.cs" />

MemPlus/Windows/MainWindow.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<Menu IsMainMenu="True">
1919
<MenuItem Header="_File">
2020
<MenuItem Header="Export">
21-
<MenuItem Header="RAM usage" />
21+
<MenuItem Header="RAM Optimizer log" />
2222
<MenuItem Header="Application logs" />
2323
</MenuItem>
2424
<Separator />
@@ -29,6 +29,8 @@
2929
<MenuItem Header="RAM Analyzer"></MenuItem>
3030
<Separator />
3131
<MenuItem Header="Logs">
32+
<MenuItem Header="RAM Optimizer log" />
33+
<Separator />
3234
<MenuItem Header="Application logs" />
3335
</MenuItem>
3436
<Separator />

MemPlus/Windows/MainWindow.xaml.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public partial class MainWindow
2020
public MainWindow()
2121
{
2222
_logController = new LogController();
23-
_logController.AddLog(new Log("Initializing MemPlus"));
23+
_logController.AddLog(new ApplicationLog("Initializing MemPlus"));
2424

2525
_logController.LogAddedEvent += LogAddedEvent;
2626

@@ -33,22 +33,23 @@ public MainWindow()
3333

3434
private static void LogAddedEvent(Log log)
3535
{
36-
Console.WriteLine("[" + log.GetDate() + "] " + log.GetValue());
36+
if (log.LogType != LogType.Application) return;
37+
Console.WriteLine("[" + log.GetDate() + "] " + log.GetData());
3738
}
3839

3940
internal void ChangeVisualStyle()
4041
{
41-
_logController.AddLog(new Log("Changing MemPlus theme style"));
42+
_logController.AddLog(new ApplicationLog("Changing MemPlus theme style"));
4243

4344
StyleManager.ChangeStyle(this);
4445
CgRamUsage.Scales[0].Ranges[0].Stroke = new SolidColorBrush(Properties.Settings.Default.MetroColor);
4546

46-
_logController.AddLog(new Log("Done changing MemPlus theme style"));
47+
_logController.AddLog(new ApplicationLog("Done changing MemPlus theme style"));
4748
}
4849

4950
private async void BtnClearMemory_OnClick(object sender, RoutedEventArgs e)
5051
{
51-
_logController.AddLog(new Log("Clearing RAM Memory"));
52+
_logController.AddLog(new ApplicationLog("Clearing RAM Memory"));
5253

5354
try
5455
{
@@ -72,7 +73,7 @@ private async void BtnClearMemory_OnClick(object sender, RoutedEventArgs e)
7273
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
7374
}
7475

75-
_logController.AddLog(new Log("Done clearing RAM memory"));
76+
_logController.AddLog(new ApplicationLog("Done clearing RAM memory"));
7677
}
7778
}
7879
}

0 commit comments

Comments
 (0)