Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the log level TRACE #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/YALV.Core/Domain/LogItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ private void assignLevelIndex(string level)
string ul = !String.IsNullOrWhiteSpace(level) ? level.Trim().ToUpper() : string.Empty;
switch (ul)
{
case "TRACE":
LevelIndex = LevelIndex.TRACE;
break;
case "DEBUG":
LevelIndex = LevelIndex.DEBUG;
break;
Expand Down Expand Up @@ -81,10 +84,11 @@ private void assignLevelIndex(string level)
public enum LevelIndex
{
NONE = 0,
DEBUG = 1,
INFO = 2,
WARN = 3,
ERROR = 4,
FATAL = 5
TRACE = 1,
DEBUG = 2,
INFO = 3,
WARN = 4,
ERROR = 5,
FATAL = 6
}
}
15 changes: 10 additions & 5 deletions src/YALV/Common/Converters/LevelToSolidColorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

namespace YALV.Common.Converters
{
using YALV.Core.Domain;

public class LevelToSolidColorConverter
: IValueConverter
{
private SolidColorBrush traceColor = Application.Current.FindResource("TraceLevelColor") as SolidColorBrush;
private SolidColorBrush debugColor = Application.Current.FindResource("DebugLevelColor") as SolidColorBrush;
private SolidColorBrush infoColor = Application.Current.FindResource("InfoLevelColor") as SolidColorBrush;
private SolidColorBrush warnColor = Application.Current.FindResource("WarnLevelColor") as SolidColorBrush;
Expand All @@ -22,15 +25,17 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
int levelIndex = (int)value;
switch (levelIndex)
{
case 1:
case (int)LevelIndex.TRACE:
return traceColor ?? Brushes.Transparent;
case (int)LevelIndex.DEBUG:
return debugColor ?? Brushes.Transparent;
case 2:
case (int)LevelIndex.INFO:
return infoColor ?? Brushes.Transparent;
case 3:
case (int)LevelIndex.WARN:
return warnColor ?? Brushes.Transparent;
case 4:
case (int)LevelIndex.ERROR:
return errorColor ?? Brushes.Transparent;
case 5:
case (int)LevelIndex.FATAL:
return fatalColor ?? Brushes.Transparent;
default:
return Brushes.Transparent;
Expand Down
30 changes: 30 additions & 0 deletions src/YALV/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@
</TextBlock.Text>
</TextBlock>
</StackPanel>
<!-- TRACE -->
<StackPanel
Margin="15,0,0,0"
Orientation="Vertical">
<ContentControl
Content="{StaticResource RadioButtonTrace}"
HorizontalAlignment="Center" />
<TextBlock
Style="{StaticResource tbCountStyle}">
<TextBlock.Text>
<MultiBinding
StringFormat="{}[ {0} / {1} ]">
<Binding
Mode="OneWay"
Path="ItemsTraceFilterCount" />
<Binding
Mode="OneWay"
Path="ItemsTraceCount" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
<!-- DEBUG -->
<StackPanel
Margin="15,0,0,0"
Expand Down Expand Up @@ -296,6 +318,14 @@
</Style>
</StackPanel.Resources>

<Border
Background="{StaticResource TraceLevelColor}">
<CheckBox
IsChecked="{Binding Path=ShowLevelTrace}"
Name="chkShowTrace"
ToolTip="TRACE" />
</Border>

<Border
Background="{StaticResource DebugLevelColor}">
<CheckBox
Expand Down
42 changes: 37 additions & 5 deletions src/YALV/Resources/GlobalResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
PresentationOptions:Freeze="True" />

<!-- LEVEL COLORS -->
<SolidColorBrush
x:Key="TraceLevelColor"
Color="LightCyan"
PresentationOptions:Freeze="True" />
<SolidColorBrush
x:Key="DebugLevelColor"
Color="LightBlue"
Expand Down Expand Up @@ -459,10 +463,19 @@
TargetType="{x:Type DataGridRow}">
<Style.Triggers>

<!-- Debug -->
<!-- Trace -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="1">
<Setter
Property="Background"
Value="{StaticResource TraceLevelColor}" />
</DataTrigger>

<!-- Debug -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="2">
<Setter
Property="Background"
Value="{StaticResource DebugLevelColor}" />
Expand All @@ -471,7 +484,7 @@
<!-- Info -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="2">
Value="3">
<Setter
Property="Background"
Value="{StaticResource InfoLevelColor}" />
Expand All @@ -480,7 +493,7 @@
<!-- Warn -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="3">
Value="4">
<Setter
Property="Background"
Value="{StaticResource WarnLevelColor}" />
Expand All @@ -489,7 +502,7 @@
<!-- Error -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="4">
Value="5">
<Setter
Property="Background"
Value="{StaticResource ErrorLevelColor}" />
Expand All @@ -498,7 +511,7 @@
<!-- Fatal -->
<DataTrigger
Binding="{Binding Path=LevelIndex, Mode=OneWay}"
Value="5">
Value="6">
<Setter
Property="Background"
Value="{StaticResource FatalLevelColor}" />
Expand Down Expand Up @@ -561,6 +574,25 @@
</DockPanel>
</Border>

<Border
Style="{StaticResource borderRbStyle}"
x:Key="RadioButtonTrace"
Background="{StaticResource TraceLevelColor}">
<DockPanel
LastChildFill="True">
<RadioButton
DockPanel.Dock="Left"
GroupName="Selection"
IsChecked="{Binding Path=SelectTrace}">
<TextBlock
VerticalAlignment="Center"
Style="{StaticResource tbRbStyle}"
Text="TRACE" />

</RadioButton>
</DockPanel>
</Border>

<Border
Style="{StaticResource borderRbStyle}"
x:Key="RadioButtonDebug"
Expand Down
Loading