Skip to content

Commit

Permalink
Merge pull request #22 from LykkeCity/Logging-system-redesign
Browse files Browse the repository at this point in the history
Logging system redesign
  • Loading branch information
KonstantinRyazantsev authored Jun 25, 2018
2 parents 90dd832 + 262fde1 commit bbf9ab7
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 16 deletions.
1 change: 1 addition & 0 deletions Lykke.Service.LykkeService/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To define your own environment variables, see [Working with multiple environment

* *ASPNETCORE_ENVIRONMENT* - defines environment name, the value can be: Development, Staging, Production.
* *SettingsUrl* - defines URL of remote settings or path for local settings.
* *APP_INFO* - define your name. This will help another developers to determine who runs service locally. Consider to define this variable in machine-wide or user-wide configuration to spread out this variable across all of the projects.

Reflect your settings structure in appsettings.json - leave all of field blank, or just show value's format. Fill appsettings.XXX.json with real settings data. Ensure that appsettings.XXX.json is ignored in git.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
using System;
using Autofac;
using Common.Log;
using Autofac.Core;
using JetBrains.Annotations;
using Lykke.Common.Log;

namespace Lykke.Service.LykkeService.Client
{
[PublicAPI]
public static class AutofacExtension
{
public static void RegisterLykkeServiceClient(this ContainerBuilder builder, string serviceUrl, ILog log)
public static void RegisterLykkeServiceClient(this ContainerBuilder builder, string serviceUrl)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
if (log == null) throw new ArgumentNullException(nameof(log));
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (string.IsNullOrWhiteSpace(serviceUrl))
{
throw new ArgumentException("Value cannot be null or whitespace.", nameof(serviceUrl));
}

builder.RegisterType<LykkeServiceClient>()
.WithParameter("serviceUrl", serviceUrl)
.As<ILykkeServiceClient>()
.SingleInstance();
}

public static void RegisterLykkeServiceClient(this ContainerBuilder builder, LykkeServiceServiceClientSettings settings, ILog log)
public static void RegisterLykkeServiceClient(this ContainerBuilder builder, LykkeServiceServiceClientSettings settings)
{
builder.RegisterLykkeServiceClient(settings?.ServiceUrl, log);
builder.RegisterLykkeServiceClient(settings?.ServiceUrl);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lykke.Common" Version="6.8.5" />
<PackageReference Include="Lykke.Common" Version="7.0.1" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.11" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System;
using Common.Log;
using JetBrains.Annotations;
using Lykke.Common.Log;

namespace Lykke.Service.LykkeService.Client
{
[PublicAPI]
public class LykkeServiceClient : ILykkeServiceClient, IDisposable
{
private readonly ILog _log;

public LykkeServiceClient(string serviceUrl, ILog log)
public LykkeServiceClient(string serviceUrl, ILogFactory logFactory)
{
_log = log;
_log = logFactory.CreateLog(this);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lykke.AzureStorage" Version="8.4.1" />
<PackageReference Include="Lykke.AzureStorage" Version="8.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lykke.Service.LykkeService.Core\Lykke.Service.LykkeService.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lykke.Common" Version="6.8.5" />
<PackageReference Include="Lykke.Common" Version="7.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lykke.Common" Version="6.8.5" />
<PackageReference Include="Lykke.Common" Version="7.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lykke.Service.LykkeService.Core\Lykke.Service.LykkeService.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lykke.Sdk" Version="1.3.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0" />
<PackageReference Include="Lykke.Sdk" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lykke.Service.LykkeService.AzureRepositories\Lykke.Service.LykkeService.AzureRepositories.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using Lykke.Sdk;
using Lykke.Service.LykkeService.Settings;
using Microsoft.AspNetCore.Builder;
Expand All @@ -7,17 +8,44 @@

namespace Lykke.Service.LykkeService
{
[UsedImplicitly]
public class Startup
{
[UsedImplicitly]
public IServiceProvider ConfigureServices(IServiceCollection services)
{
return services.BuildServiceProvider<AppSettings>(options =>
{
options.ApiTitle = "LykkeService API";
options.Logs = ("LykkeServiceLog", ctx => ctx.LykkeServiceService.Db.LogsConnString);
options.Logs = logs =>
{
logs.AzureTableName = "LykkeServiceLog";
logs.AzureTableConnectionStringResolver = settings => settings.LykkeServiceService.Db.LogsConnString;
// TODO: You could add extended logging configuration here:
/*
logging.Extended = extendedLogging =>
{
// For example, you could add additional slack channel like this:
extendedLogging.AddAdditionalSlackChannel("LykkeService", channelOptions =>
{
channelOptions.MinLogLevel = LogLevel.Information;
});
};
*/
};
// TODO: You could add extended Swagger configuration here:
/*
options.Swagger = swagger =>
{
swagger.IgnoreObsoleteActions();
}
*/
});
}

[UsedImplicitly]
public void Configure(IApplicationBuilder app)
{
app.UseLykkeConfiguration();
Expand Down

0 comments on commit bbf9ab7

Please sign in to comment.