2023-03-18 18:09:36 +03:00
|
|
|
|
using System.IO;
|
|
|
|
|
using DotRecast.Core;
|
2023-04-23 08:03:35 +03:00
|
|
|
|
using DotRecast.Recast.Demo.Logging.Sinks;
|
2023-03-18 22:36:31 +03:00
|
|
|
|
using Serilog;
|
2023-03-20 18:33:17 +03:00
|
|
|
|
using Serilog.Enrichers;
|
2023-03-18 18:09:36 +03:00
|
|
|
|
|
|
|
|
|
namespace DotRecast.Recast.Demo;
|
2023-03-14 17:56:10 +03:00
|
|
|
|
|
|
|
|
|
public static class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2023-04-30 13:19:37 +03:00
|
|
|
|
InitializeWorkingDirectory();
|
2023-06-07 17:14:15 +03:00
|
|
|
|
InitializeLogger();
|
2023-04-30 13:19:37 +03:00
|
|
|
|
StartDemo();
|
|
|
|
|
}
|
2023-03-18 18:09:36 +03:00
|
|
|
|
|
2023-04-30 13:19:37 +03:00
|
|
|
|
private static void InitializeLogger()
|
|
|
|
|
{
|
2023-04-16 05:54:50 +03:00
|
|
|
|
var format = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level:u3}] {Message:lj} [{ThreadName}:{ThreadId}]{NewLine}{Exception}";
|
2023-03-19 08:39:44 +03:00
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
|
|
.MinimumLevel.Verbose()
|
2023-03-20 18:33:17 +03:00
|
|
|
|
.Enrich.WithThreadId()
|
|
|
|
|
.Enrich.WithThreadName()
|
|
|
|
|
.Enrich.WithProperty(ThreadNameEnricher.ThreadNamePropertyName, "main")
|
2023-04-24 17:18:48 +03:00
|
|
|
|
.WriteTo.Async(c => c.LogMessageBroker(outputTemplate: format))
|
|
|
|
|
.WriteTo.Async(c => c.Console(outputTemplate: format))
|
|
|
|
|
.WriteTo.Async(c => c.File(
|
2023-03-20 18:33:17 +03:00
|
|
|
|
"logs/log.log",
|
2023-06-07 17:14:15 +03:00
|
|
|
|
rollingInterval: RollingInterval.Hour,
|
2023-03-20 18:33:17 +03:00
|
|
|
|
rollOnFileSizeLimit: true,
|
2023-06-07 17:14:15 +03:00
|
|
|
|
retainedFileCountLimit: null,
|
2023-03-20 18:33:17 +03:00
|
|
|
|
outputTemplate: format)
|
2023-04-24 17:18:48 +03:00
|
|
|
|
)
|
2023-03-19 08:39:44 +03:00
|
|
|
|
.CreateLogger();
|
2023-04-30 13:19:37 +03:00
|
|
|
|
}
|
2023-03-20 18:33:17 +03:00
|
|
|
|
|
2023-04-30 13:19:37 +03:00
|
|
|
|
private static void InitializeWorkingDirectory()
|
|
|
|
|
{
|
|
|
|
|
var path = Loader.ToRPath("dungeon.obj");
|
|
|
|
|
path = Path.GetDirectoryName(path);
|
|
|
|
|
if (!string.IsNullOrEmpty(path))
|
|
|
|
|
{
|
|
|
|
|
var workingDirectory = Path.Combine(path, "..");
|
|
|
|
|
workingDirectory = Path.GetFullPath(workingDirectory);
|
|
|
|
|
Directory.SetCurrentDirectory(workingDirectory);
|
|
|
|
|
}
|
2023-04-17 18:12:28 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-30 13:19:37 +03:00
|
|
|
|
private static void StartDemo()
|
2023-04-17 18:12:28 +03:00
|
|
|
|
{
|
2023-03-14 17:56:10 +03:00
|
|
|
|
var demo = new RecastDemo();
|
2023-04-17 18:12:28 +03:00
|
|
|
|
demo.Run();
|
2023-03-14 17:56:10 +03:00
|
|
|
|
}
|
|
|
|
|
}
|