Add Serilog and configure logger
This commit is contained in:
parent
b8c16a1ffc
commit
19aefb6ac5
|
@ -7,4 +7,8 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DotMake.CommandLine" Version="1.8.8" />
|
<PackageReference Include="DotMake.CommandLine" Version="1.8.8" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="TinyEmbree" Version="1.0.3" />
|
<PackageReference Include="TinyEmbree" Version="1.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,31 @@
|
||||||
using DotMake.CommandLine;
|
using DotMake.CommandLine;
|
||||||
|
using Serilog;
|
||||||
|
using Serilog.Sinks.SystemConsole.Themes;
|
||||||
|
|
||||||
namespace KeepersCompound.Lightmapper;
|
namespace KeepersCompound.Lightmapper;
|
||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
public static async Task<int> Main(string[] args) =>
|
private static void ConfigureLogger()
|
||||||
await Cli.RunAsync<LightCommand>(args);
|
{
|
||||||
|
const string outputTemplate = "{Timestamp:HH:mm:ss.fff} [{Level}] {Message:lj}{NewLine}{Exception}";
|
||||||
|
var logPath = $"{AppDomain.CurrentDomain.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd_HHmmss}.log";
|
||||||
|
var config = new LoggerConfiguration();
|
||||||
|
#if DEBUG
|
||||||
|
config.MinimumLevel.Debug();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Log.Logger = config
|
||||||
|
.WriteTo.Console(theme: AnsiConsoleTheme.Sixteen, outputTemplate: outputTemplate)
|
||||||
|
.WriteTo.File(logPath, outputTemplate: outputTemplate)
|
||||||
|
.CreateLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<int> Main(string[] args)
|
||||||
|
{
|
||||||
|
ConfigureLogger();
|
||||||
|
return await Cli.RunAsync<LightCommand>(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[CliCommand(Description = "Compute lightmaps for a NewDark .MIS/.COW")]
|
[CliCommand(Description = "Compute lightmaps for a NewDark .MIS/.COW")]
|
||||||
|
|
Loading…
Reference in New Issue