Skip to content

Commit bb0306c

Browse files
committed
Replaced string compare by RegEx.
1 parent 2c8f04c commit bb0306c

File tree

5 files changed

+81
-56
lines changed

5 files changed

+81
-56
lines changed

src/Logbert/App.config

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,23 @@
580580
<setting name="ColumnizerRepository" serializeAs="String">
581581
<value>columnizer.xml</value>
582582
</setting>
583-
<setting name="LevelTRACE" serializeAs="String">
584-
<value>TRACE;</value>
583+
<setting name="Log4NetLevelTrace" serializeAs="String">
584+
<value>TRACE</value>
585585
</setting>
586-
<setting name="LevelDEBUG" serializeAs="String">
587-
<value>DEBUG;</value>
586+
<setting name="Log4NetLevelDebug" serializeAs="String">
587+
<value>DEBUG</value>
588588
</setting>
589-
<setting name="LevelINFO" serializeAs="String">
590-
<value>INFO;</value>
589+
<setting name="Log4NetLevelInfo" serializeAs="String">
590+
<value>INFO</value>
591591
</setting>
592-
<setting name="LevelWARN" serializeAs="String">
593-
<value>WARN;</value>
592+
<setting name="Log4NetLeveLWarning" serializeAs="String">
593+
<value>WARN</value>
594594
</setting>
595-
<setting name="LevelERROR" serializeAs="String">
596-
<value>ERROR;</value>
595+
<setting name="Log4NetLevelError" serializeAs="String">
596+
<value>ERROR</value>
597597
</setting>
598-
<setting name="LevelFATAL" serializeAs="String">
599-
<value>FATAL;</value>
598+
<setting name="Log4NetLevelFatal" serializeAs="String">
599+
<value>FATAL</value>
600600
</setting>
601601
</Couchcoding.Logbert.Properties.Settings>
602602
</applicationSettings>

src/Logbert/Logbert.csproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@
3030
</UpgradeBackupLocation>
3131
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
3232
<TargetFrameworkProfile />
33+
<PublishUrl>publish\</PublishUrl>
34+
<Install>true</Install>
35+
<InstallFrom>Disk</InstallFrom>
36+
<UpdateEnabled>false</UpdateEnabled>
37+
<UpdateMode>Foreground</UpdateMode>
38+
<UpdateInterval>7</UpdateInterval>
39+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
40+
<UpdatePeriodically>false</UpdatePeriodically>
41+
<UpdateRequired>false</UpdateRequired>
42+
<MapFileExtensions>true</MapFileExtensions>
43+
<ApplicationRevision>0</ApplicationRevision>
44+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
45+
<IsWebBootstrapper>false</IsWebBootstrapper>
46+
<UseApplicationTrust>false</UseApplicationTrust>
47+
<BootstrapperEnabled>true</BootstrapperEnabled>
3348
</PropertyGroup>
3449
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
3550
<DebugSymbols>true</DebugSymbols>
@@ -642,6 +657,13 @@
642657
<Name>Couchcoding.Logbert.Theme</Name>
643658
</ProjectReference>
644659
</ItemGroup>
660+
<ItemGroup>
661+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
662+
<Visible>False</Visible>
663+
<ProductName>.NET Framework 3.5 SP1</ProductName>
664+
<Install>false</Install>
665+
</BootstrapperPackage>
666+
</ItemGroup>
645667
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
646668
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
647669
Other similar extension points exist, see Microsoft.Common.targets.

src/Logbert/Logging/LogMessageLog4Net.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
using MoonSharp.Interpreter;
4040
using System.Globalization;
41+
using System.Text.RegularExpressions;
4142

4243
namespace Couchcoding.Logbert.Logging
4344
{
@@ -249,7 +250,7 @@ private bool ParseData(string data)
249250
}
250251

251252
long timestamp;
252-
mTimestamp = long.TryParse(reader.GetAttribute("timestamp"), out timestamp)
253+
mTimestamp = long.TryParse(reader.GetAttribute("timestamp"), out timestamp)
253254
? mUtcStartDate.AddMilliseconds(timestamp)
254255
: DateTime.Now;
255256

@@ -325,27 +326,29 @@ private bool ParseData(string data)
325326
/// <returns>The mapped <see cref="LogLevel"/>.</returns>
326327
private LogLevel MapLevelType(string levelType)
327328
{
328-
if (!string.IsNullOrEmpty(levelType))
329+
if (!string.IsNullOrEmpty(levelType))
329330
{
330-
var level = levelType;
331-
if (Settings.Default.LevelTRACE.Split(';').Any(x=>String.Equals(x,level,StringComparison.CurrentCultureIgnoreCase)))
332-
{
333-
return LogLevel.Trace;
334-
}
335-
else if (Settings.Default.LevelDEBUG.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
336-
331+
if (Regex.IsMatch(levelType, Settings.Default.Log4NetLevelDebug))
337332
{
338333
return LogLevel.Debug;
339334
}
340-
else if (Settings.Default.LevelINFO.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
335+
336+
if (Regex.IsMatch(levelType, Settings.Default.Log4NetLevelInfo))
341337
{
342338
return LogLevel.Info;
343339
}
344-
else if (Settings.Default.LevelWARN.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
340+
341+
if (Regex.IsMatch(levelType, Settings.Default.Log4NetLeveLWarning))
345342
{
346343
return LogLevel.Warning;
347344
}
348-
else if (Settings.Default.LevelFATAL.Split(';').Any(x => String.Equals(x, level, StringComparison.CurrentCultureIgnoreCase)))
345+
346+
if (Regex.IsMatch(levelType, Settings.Default.Log4NetLevelError))
347+
{
348+
return LogLevel.Error;
349+
}
350+
351+
if (Regex.IsMatch(levelType, Settings.Default.Log4NetLevelFatal))
349352
{
350353
return LogLevel.Fatal;
351354
}

src/Logbert/Properties/Settings.Designer.cs

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Properties/Settings.settings

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,23 +536,23 @@
536536
<Setting Name="FrmMainShowWelcomePage" Type="System.Boolean" Scope="User">
537537
<Value Profile="(Default)">True</Value>
538538
</Setting>
539-
<Setting Name="LevelTRACE" Type="System.String" Scope="Application">
540-
<Value Profile="(Default)">TRACE;</Value>
539+
<Setting Name="Log4NetLevelTrace" Type="System.String" Scope="Application">
540+
<Value Profile="(Default)">TRACE</Value>
541541
</Setting>
542-
<Setting Name="LevelDEBUG" Type="System.String" Scope="Application">
543-
<Value Profile="(Default)">DEBUG;</Value>
542+
<Setting Name="Log4NetLevelDebug" Type="System.String" Scope="Application">
543+
<Value Profile="(Default)">DEBUG</Value>
544544
</Setting>
545-
<Setting Name="LevelINFO" Type="System.String" Scope="Application">
546-
<Value Profile="(Default)">INFO;</Value>
545+
<Setting Name="Log4NetLevelInfo" Type="System.String" Scope="Application">
546+
<Value Profile="(Default)">INFO</Value>
547547
</Setting>
548-
<Setting Name="LevelWARN" Type="System.String" Scope="Application">
549-
<Value Profile="(Default)">WARN;</Value>
548+
<Setting Name="Log4NetLeveLWarning" Type="System.String" Scope="Application">
549+
<Value Profile="(Default)">WARN</Value>
550550
</Setting>
551-
<Setting Name="LevelERROR" Type="System.String" Scope="Application">
552-
<Value Profile="(Default)">ERROR;</Value>
551+
<Setting Name="Log4NetLevelError" Type="System.String" Scope="Application">
552+
<Value Profile="(Default)">ERROR</Value>
553553
</Setting>
554-
<Setting Name="LevelFATAL" Type="System.String" Scope="Application">
555-
<Value Profile="(Default)">FATAL;</Value>
554+
<Setting Name="Log4NetLevelFatal" Type="System.String" Scope="Application">
555+
<Value Profile="(Default)">FATAL</Value>
556556
</Setting>
557557
</Settings>
558558
</SettingsFile>

0 commit comments

Comments
 (0)