-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ๐จ LogConsole * ๐ ref * ๐ ProxyLog UI * ๐ WebApplication Logging * ๐ Misc * ๐จ Log format * ๐จ LogConsoleService.ConsoleMaxCharCount * ๐ Misc --------- Co-authored-by: Aigio Liu <[email protected]>
- Loading branch information
Showing
18 changed files
with
636 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/ProxyChartView.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/ProxyLog.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<UserControl | ||
x:Class="BD.WTTS.UI.Views.Controls.ProxyLog" | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:AvaloniaEdit="using:AvaloniaEdit" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:s="https://steampp.net/services" | ||
xmlns:spp="https://steampp.net/ui" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
mc:Ignorable="d"> | ||
<Border Background="{DynamicResource CardBackgroundFillColorDefaultBrush}" CornerRadius="{DynamicResource ControlCornerRadius}"> | ||
<AvaloniaEdit:TextEditor | ||
x:Name="LogTextbox" | ||
HorizontalScrollBarVisibility="Disabled" | ||
IsReadOnly="True" | ||
ShowLineNumbers="True" /> | ||
</Border> | ||
</UserControl> |
92 changes: 92 additions & 0 deletions
92
src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/ProxyLog.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Threading; | ||
using Avalonia.VisualTree; | ||
using AvaloniaEdit; | ||
using AvaloniaEdit.TextMate; | ||
using Org.BouncyCastle.Math; | ||
using TextMateSharp.Grammars; | ||
|
||
namespace BD.WTTS.UI.Views.Controls; | ||
|
||
public partial class ProxyLog : UserControl | ||
{ | ||
CancellationTokenSource cancellation = new(); | ||
|
||
public ProxyLog() | ||
{ | ||
InitializeComponent(); | ||
|
||
var logTextbox = this.FindControl<TextEditor>("LogTextbox")!; | ||
|
||
//Here we initialize RegistryOptions with the theme we want to use. | ||
var registryOptions = new TextMateSharp.Grammars.RegistryOptions(ThemeName.Dark); | ||
|
||
//Initial setup of TextMate. | ||
var textMateInstallation = logTextbox.InstallTextMate(registryOptions); | ||
|
||
//Here we are getting the language by the extension and right after that we are initializing grammar with this language. | ||
//And that's all ๐, you are ready to use AvaloniaEdit with syntax highlighting! | ||
textMateInstallation.SetGrammar(registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".log").Id)); | ||
|
||
//logTextbox.Text = LogText; | ||
//logTextbox.ScrollToLine(logTextbox.Document.LineCount); | ||
|
||
logTextbox.TextChanged += LogTextbox_TextChanged; | ||
|
||
ProxyService.Current.WhenAnyValue(x => x.ProxyStatus) | ||
.Subscribe(x => | ||
{ | ||
if (x) | ||
{ | ||
cancellation = new CancellationTokenSource(); | ||
Task2.InBackground(FlushLogsAsync, true); | ||
} | ||
else | ||
{ | ||
if (cancellation != null) | ||
{ | ||
cancellation.Cancel(); | ||
cancellation.Dispose(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void LogTextbox_TextChanged(object? sender, EventArgs e) | ||
{ | ||
LogTextbox.ScrollToLine(LogTextbox.Document.LineCount); | ||
} | ||
|
||
void FlushLogsAsync() | ||
{ | ||
while (!cancellation.IsCancellationRequested) | ||
{ | ||
try | ||
{ | ||
var isAttachedToVisualTree = this.IsAttachedToVisualTree(); | ||
if (isAttachedToVisualTree) | ||
{ | ||
var logtext = IReverseProxyService.Constants.Instance.GetLogAllMessage(); | ||
if (string.IsNullOrEmpty(logtext)) | ||
{ | ||
Thread.Sleep(1000); | ||
continue; | ||
} | ||
|
||
Dispatcher.UIThread.Post(() => | ||
{ | ||
if (LogTextbox.Text.Length != logtext.Length) | ||
LogTextbox.Text = logtext; | ||
}); | ||
} | ||
} | ||
catch | ||
{ | ||
} | ||
finally | ||
{ | ||
Thread.Sleep(1000); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.