Skip to content

Commit

Permalink
Dependencies cleanup and support for .net core 2
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-mirza committed Sep 24, 2017
1 parent 5e44db6 commit d604a22
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 75 deletions.
12 changes: 1 addition & 11 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

& dotnet restore --no-cache

$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
Expand All @@ -15,15 +14,6 @@ $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch

echo "build: Version suffix is $suffix"

foreach ($src in ls src/*) {
Push-Location $src

echo "build: Packaging project in $src"

& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
if($LASTEXITCODE -ne 0) { exit 1 }

Pop-Location
}
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix

Pop-Location
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ image: Visual Studio 2017
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.1/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
- ps: Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.1'
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version latest -Channel 2.0'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
build_script:
- ps: ./Build.ps1
Expand All @@ -16,7 +16,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: 5NzX+3JGesw5+I2evIW9JfCOThGMc+Em9v4PUMBfkaIBIfraXpkoPTGrTHfm/SMw
secure: 3ysm3o1yzrnGt77dtYnAwQGR+XPT4Kuyjh9MuB9IrhQ/s+TE30X6v9LhRD1f7PVr
skip_symbols: true
on:
branch: /^(master)$/
branch: /^(master|dev)$/
70 changes: 34 additions & 36 deletions src/Serilog.Sinks.SQLite/Serilog.Sinks.SQLite.csproj
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyTitle>Serilog.Sinks.SQLite</AssemblyTitle>
<Authors>Saleem Mirza</Authors>
<AssemblyName>Serilog.Sinks.SQLite</AssemblyName>
<Description>Serilog event sink that writes to SQLite database</Description>
<PackageId>Serilog.Sinks.SQLite</PackageId>
<PackageTags>serilog;logging;SQLite</PackageTags>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<Copyright>Copyright © Zethian Inc. 2013-2017</Copyright>
<AssemblyVersion>3.8.5.0</AssemblyVersion>
<Version>3.8.5</Version>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>Serilog.snk</AssemblyOriginatorKeyFile>
<TargetFrameworks>netcoreapp1.0;net451</TargetFrameworks>
<FileVersion>3.8.5.0</FileVersion>
</PropertyGroup>
<PropertyGroup>
<AssemblyTitle>Serilog.Sinks.SQLite</AssemblyTitle>
<Authors>Saleem Mirza</Authors>
<AssemblyName>Serilog.Sinks.SQLite</AssemblyName>
<Description>Serilog event sink that writes to SQLite database</Description>
<PackageId>Serilog.Sinks.SQLite</PackageId>
<PackageTags>serilog;logging;SQLite</PackageTags>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<Copyright>Copyright © Zethian Inc. 2013-2017</Copyright>
<AssemblyVersion>3.9.0.0</AssemblyVersion>
<Version>3.9.0</Version>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>Serilog.snk</AssemblyOriginatorKeyFile>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<FileVersion>3.9.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(VersionSuffix)'!='' ">
<Version>$(Version)-$(VersionSuffix)</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(VersionSuffix)'!='' ">
<Version>$(Version)-$(VersionSuffix)</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="Serilog" Version="2.4.0" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="SQLite.Native" Version="3.12.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.105.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452'">
<Reference Include="System"/>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

</Project>
32 changes: 16 additions & 16 deletions src/Serilog.Sinks.SQLite/Sinks/SQLite/SQLiteSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
using System;
using System.Collections.Generic;
using System.Data;
using Microsoft.Data.Sqlite;
using Serilog.Core;
using Serilog.Debugging;
using Serilog.Events;
using Serilog.Sinks.Batch;
using System.Diagnostics;
using System.Linq;
using Serilog.Sinks.Extensions;
using System.Data.SQLite;

namespace Serilog.Sinks.SQLite
{
Expand All @@ -49,12 +49,12 @@ public SQLiteSink(string sqlLiteDbPath,
if (retentionPeriod.HasValue)
// impose a min retention period of 1 minute
_retentionPeriod = new[] { retentionPeriod.Value, TimeSpan.FromMinutes(1) }.Max();

InitializeDatabase();
}

private static string CreateConnectionString(string dbPath) =>
new SqliteConnectionStringBuilder { DataSource = dbPath }.ConnectionString;
new SQLiteConnectionStringBuilder { DataSource = dbPath }.ConnectionString;

#region ILogEvent implementation

Expand All @@ -71,14 +71,14 @@ private void InitializeDatabase()
CreateSqlTable(conn);
}

private SqliteConnection GetSqLiteConnection()
private SQLiteConnection GetSqLiteConnection()
{
var sqlConnection = new SqliteConnection(_connString);
var sqlConnection = new SQLiteConnection(_connString);
sqlConnection.Open();
return sqlConnection;
}

private void CreateSqlTable(SqliteConnection sqlConnection)
private void CreateSqlTable(SQLiteConnection sqlConnection)
{
var colDefs = "id INTEGER PRIMARY KEY AUTOINCREMENT,";
colDefs += "Timestamp TEXT,";
Expand All @@ -89,11 +89,11 @@ private void CreateSqlTable(SqliteConnection sqlConnection)

var sqlCreateText = $"CREATE TABLE IF NOT EXISTS {_tableName} ({colDefs})";

var sqlCommand = new SqliteCommand(sqlCreateText, sqlConnection);
var sqlCommand = new SQLiteCommand(sqlCreateText, sqlConnection);
sqlCommand.ExecuteNonQuery();
}

private SqliteCommand CreateSqlInsertCommand(SqliteConnection connection)
private SQLiteCommand CreateSqlInsertCommand(SQLiteConnection connection)
{
var sqlInsertText = "INSERT INTO {0} (Timestamp, Level, Exception, RenderedMessage, Properties)";
sqlInsertText += " VALUES (@timeStamp, @level, @exception, @renderedMessage, @properties)";
Expand All @@ -103,11 +103,11 @@ private SqliteCommand CreateSqlInsertCommand(SqliteConnection connection)
sqlCommand.CommandText = sqlInsertText;
sqlCommand.CommandType = CommandType.Text;

sqlCommand.Parameters.Add(new SqliteParameter("@timeStamp", DbType.DateTime2));
sqlCommand.Parameters.Add(new SqliteParameter("@level", DbType.String));
sqlCommand.Parameters.Add(new SqliteParameter("@exception", DbType.String));
sqlCommand.Parameters.Add(new SqliteParameter("@renderedMessage", DbType.String));
sqlCommand.Parameters.Add(new SqliteParameter("@properties", DbType.String));
sqlCommand.Parameters.Add(new SQLiteParameter("@timeStamp", DbType.DateTime2));
sqlCommand.Parameters.Add(new SQLiteParameter("@level", DbType.String));
sqlCommand.Parameters.Add(new SQLiteParameter("@exception", DbType.String));
sqlCommand.Parameters.Add(new SQLiteParameter("@renderedMessage", DbType.String));
sqlCommand.Parameters.Add(new SQLiteParameter("@properties", DbType.String));

return sqlCommand;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ protected override void WriteLogEvent(ICollection<LogEvent> logEventsBatch)
}
}

private void ApplyRetentionPolicy(SqliteConnection sqlConnection)
private void ApplyRetentionPolicy(SQLiteConnection sqlConnection)
{
if (!_retentionPeriod.HasValue)
// there is no retention policy
Expand All @@ -180,11 +180,11 @@ private void ApplyRetentionPolicy(SqliteConnection sqlConnection)
_retentionWatch.Restart();
}

private SqliteCommand CreateSqlDeleteCommand(SqliteConnection sqlConnection, DateTimeOffset epoch)
private SQLiteCommand CreateSqlDeleteCommand(SQLiteConnection sqlConnection, DateTimeOffset epoch)
{
var cmd = sqlConnection.CreateCommand();
cmd.CommandText = $"DELETE FROM {_tableName} WHERE Timestamp < @epoch";
cmd.Parameters.Add(new SqliteParameter("@epoch", DbType.DateTime2)
cmd.Parameters.Add(new SQLiteParameter("@epoch", DbType.DateTime2)
{
Value = _storeTimestampInUtc ? epoch.ToUniversalTime() : epoch
});
Expand Down
8 changes: 0 additions & 8 deletions src/Serilog.Sinks.SQLite/packages.config

This file was deleted.

0 comments on commit d604a22

Please sign in to comment.