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

Final 2022.1 updates #231

Merged
merged 2 commits into from
Mar 15, 2022
Merged
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
2 changes: 1 addition & 1 deletion Setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ New-Item -ItemType Directory -Force "./build/" | Out-Null

Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./build/installcli.ps1"
& ./build/installcli.ps1 -InstallDir "$pwd/.dotnetcli" -NoPath -Version $RequiredDotnetVersion
if ($LASTEXITCODE) { exit 1 }
if ($LASTEXITCODE) { throw ".NET install failed" }

$env:Path = "$pwd/.dotnetcli;$env:Path"
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for:
- image: Ubuntu1804

install:
- ./setup.sh
- pwsh: ./setup.sh

build_script:
- pwsh: $env:PATH = "$env:HOME/.dotnetcli:$env:PATH"; ./Build.Docker.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)"
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.101"
"version": "6.0.201"
}
}
4 changes: 3 additions & 1 deletion seqcli.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MS/@EntryIndexedValue">MS</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=apikey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=appinstance/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=appinstances/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -30,4 +31,5 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=syslogdt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tokenizes/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=trailingindent/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unawaited/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unawaited/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=xmpweb/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
28 changes: 19 additions & 9 deletions src/SeqCli/Cli/Commands/SearchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Seq.Api.Model.Events;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand All @@ -27,6 +26,9 @@
using Serilog;
using Serilog.Events;
using Serilog.Parsing;
// ReSharper disable UnusedType.Global

#nullable enable

namespace SeqCli.Cli.Commands
{
Expand All @@ -39,8 +41,9 @@ class SearchCommand : Command
readonly OutputFormatFeature _output;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
string _filter;
string? _filter;
int _count = 1;
int _httpClientTimeout = 100000;

public SearchCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All @@ -58,6 +61,12 @@ public SearchCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
_range = Enable<DateRangeFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_signal = Enable<SignalExpressionFeature>();

Options.Add(
"request-timeout=",
$"The time allowed for retrieving each page of events, in milliseconds; the default is {_httpClientTimeout}",
v => _httpClientTimeout = int.Parse(v.Trim()));

_connection = Enable<ConnectionFeature>();
}

Expand All @@ -67,15 +76,16 @@ protected override async Task<int> Run()
{
using var output = _output.CreateOutputLogger();
var connection = _connectionFactory.Connect(_connection);
connection.Client.HttpClient.Timeout = TimeSpan.FromMilliseconds(_httpClientTimeout);

string filter = null;
string? filter = null;
if (!string.IsNullOrWhiteSpace(_filter))
filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression;

await foreach (var evt in connection.Events.EnumerateAsync(null,
_signal.Signal,
filter: filter,
count: _count,
filter,
_count,
fromDateUtc: _range.Start,
toDateUtc: _range.End))
{
Expand Down Expand Up @@ -103,13 +113,13 @@ LogEvent ToSerilogEvent(EventEntity evt)
.Concat(new[] { new LogEventProperty(SurrogateLevelProperty.PropertyName, new ScalarValue(evt.Level)) }));
}

static MessageTemplateToken ToMessageTemplateToken(MessageTemplateTokenPart mttp)
static MessageTemplateToken ToMessageTemplateToken(MessageTemplateTokenPart token)
{
// Not ideal, we lose renderings, alignment etc. here.

if (mttp.Text != null)
return new TextToken(mttp.Text);
return new PropertyToken(mttp.PropertyName, mttp.RawText ?? $"{{{mttp.PropertyName}}}");
if (token.Text != null)
return new TextToken(token.Text);
return new PropertyToken(token.PropertyName, token.RawText ?? $"{{{token.PropertyName}}}");
}

LogEventProperty CreateProperty(string name, object value)
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/SeqCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<PackageReference Include="Superpower" Version="3.0.0" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="6.0.0" />
<PackageReference Include="Seq.Api" Version="2022.1.0-dev-00184" />
<PackageReference Include="Seq.Api" Version="2022.1.0" />
<PackageReference Include="Seq.Apps" Version="2021.4.0" />
<!-- Seq.Api pulls in Tavis.UriTemplates which pulls in version 1.6.0 of this package, causing
package downgrade warnings. -->
Expand Down
2 changes: 1 addition & 1 deletion test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="Data\*">
Expand Down
2 changes: 1 addition & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net6.0;net6.0-windows</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down