58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Threading;
|
|
using Serilog;
|
|
using Serilog.Formatting.Display;
|
|
using Serilog.Sinks.LogEmAll;
|
|
|
|
namespace DatEmAll_CLI
|
|
{
|
|
/// <summary>
|
|
/// The Main Program Class.
|
|
/// </summary>
|
|
class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
static void Main(string[] args)
|
|
{
|
|
// Configure the Logger.
|
|
ConfigureSerilog();
|
|
|
|
// Create a new program object.
|
|
DatEmAll.DatEmAll dea = new DatEmAll.DatEmAll();
|
|
|
|
// Set the title.
|
|
dea.UpdateTitle();
|
|
|
|
// Print the version.
|
|
dea.PrintVersion();
|
|
|
|
// Load the default options passed from the default options file.
|
|
dea.LoadOptionsFromFile();
|
|
|
|
// Load the default options passed from the command line arguments.
|
|
dea.LoadOptionsFromCLI(args);
|
|
|
|
// Process the command switch.
|
|
dea.ProcessCommandSwitch();
|
|
|
|
// Output the log to a text file.
|
|
dea.SaveLogToFile();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure the logger.
|
|
/// </summary>
|
|
public static void ConfigureSerilog()
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
.MinimumLevel.Information()
|
|
.WriteTo.Console(outputTemplate: "{Level:u4}: {Message:lj}{NewLine}{Exception}")
|
|
.WriteToListString(new MessageTemplateTextFormatter("{Level:u4}: {Message:lj}{Exception}"))
|
|
.CreateLogger();
|
|
}
|
|
}
|
|
}
|