-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Game don't need secrets. It's a client app
- Loading branch information
Showing
10 changed files
with
115 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace GameDesktop; | ||
|
||
internal static class ConfigurationFactory | ||
{ | ||
private const string AppSettingsName = "appsettings"; | ||
private const string EnvironmentVariableName = "DOTNET_ENVIRONMENT"; | ||
|
||
private static string BasePath => Directory.GetParent(AppContext.BaseDirectory)!.FullName; | ||
|
||
private static string CurrentEnvironment => | ||
Environment.GetEnvironmentVariable(EnvironmentVariableName) ?? "Production"; | ||
|
||
private static readonly string EnvironmentAppSettingsName = | ||
$"{AppSettingsName}.{CurrentEnvironment}"; | ||
|
||
private static string BuildJsonFileName(string fileName) => $"{fileName}.json"; | ||
|
||
public static IConfigurationRoot Create() => | ||
new ConfigurationBuilder() | ||
.SetBasePath(BasePath) | ||
.AddJsonFile(BuildJsonFileName(AppSettingsName), optional: false, reloadOnChange: true) | ||
.AddJsonFile(BuildJsonFileName(EnvironmentAppSettingsName), optional: true) | ||
.AddEnvironmentVariables() | ||
.Build(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,13 @@ | ||
using Serilog; | ||
using Microsoft.Extensions.Configuration; | ||
using Serilog; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
|
||
namespace GameDesktop; | ||
|
||
internal static class LogFactory | ||
{ | ||
private const LogEventLevel MinimumLevel = LogEventLevel.Verbose; | ||
private const string FilePath = "logs/log-.txt"; | ||
|
||
private const string OutputTemplate = | ||
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj} {NewLine}{Exception}"; | ||
|
||
private const bool DoSentryDebug = false; | ||
private const LogEventLevel SentryMinimumBreadcrumbLevel = LogEventLevel.Debug; | ||
|
||
// TODO: Put it in env | ||
private const string SentryDsn = | ||
"https://ff3f6fec4457d740ab0a98c123e77086@o4505883399487488.ingest.sentry.io/4505883401388032"; | ||
|
||
public static Logger Create() => | ||
public static Logger Create(IConfiguration configuration) => | ||
new LoggerConfiguration() | ||
.MinimumLevel.Is(MinimumLevel) | ||
.Enrich.FromLogContext() | ||
.WriteTo.File(FilePath, | ||
outputTemplate: OutputTemplate, | ||
rollingInterval: RollingInterval.Day) | ||
.WriteTo.Console(outputTemplate: OutputTemplate) | ||
.WriteTo.Sentry(options => | ||
{ | ||
// Debug and higher are stored as breadcrumbs (default is Information) | ||
options.MinimumBreadcrumbLevel = SentryMinimumBreadcrumbLevel; | ||
options.Debug = DoSentryDebug; | ||
options.Dsn = SentryDsn; | ||
}) | ||
.ReadFrom.Configuration(configuration) | ||
.CreateLogger(); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"GameDesktop": { | ||
"commandName": "Project", | ||
"environmentVariables": { | ||
"DOTNET_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |
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,42 @@ | ||
{ | ||
"Serilog": { | ||
"Using": [ | ||
"Serilog.Sinks.Console", | ||
"Serilog.Sinks.File" | ||
], | ||
"MinimumLevel": "Verbose", | ||
"Enrich": [ | ||
"FromLogContext" | ||
], | ||
"WriteTo": [ | ||
{ | ||
"Name": "Console", | ||
"Args": { | ||
"outputTemplate": "[{Level:u3}] [{SourceContext}] {Message:lj} {NewLine}{Exception}", | ||
"theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Colored, Serilog.Sinks.Console" | ||
} | ||
}, | ||
{ | ||
"Name": "File", | ||
"Args": { | ||
"path": "%APPDATA%/GameDesktop/Logs/log-.txt", | ||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj} {NewLine}{Exception}", | ||
"rollingInterval": "Day" | ||
} | ||
}, | ||
{ | ||
"Name": "Sentry", | ||
"Args": { | ||
"EnableTracing": true, | ||
"MaxRequestBodySize": "Always", | ||
"SendDefaultPii": true, | ||
"IncludeActivityData": true, | ||
"AttachStackTrace": true, | ||
"Debug": true, | ||
"Dsn": "https://ff3f6fec4457d740ab0a98c123e77086@o4505883399487488.ingest.sentry.io/4505883401388032", | ||
"DiagnosticLevel": "Error" | ||
} | ||
} | ||
] | ||
} | ||
} |