55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using Serilog;
|
|
using Serilog.Formatting.Display;
|
|
using Serilog.Sinks.LogEmAll;
|
|
|
|
namespace PatchEmAll_CLI
|
|
{
|
|
/// <summary>
|
|
/// The Main Program Class.
|
|
/// </summary>
|
|
class Program
|
|
{
|
|
/// <summary>
|
|
/// The Main entry point for the program.
|
|
/// </summary>
|
|
static void Main(string[] args)
|
|
{
|
|
// Configure the Logger.
|
|
ConfigureSerilog();
|
|
|
|
// Create a new program object.
|
|
PatchEmAll.PatchEmAll pea = new PatchEmAll.PatchEmAll();
|
|
|
|
// Set the title.
|
|
pea.UpdateTitle();
|
|
|
|
// Print the version.
|
|
pea.PrintVersion();
|
|
|
|
// Load the default options passed from the default options file.
|
|
pea.LoadOptionsFromFile();
|
|
|
|
// Load the default options passed from the command line arguments.
|
|
pea.LoadOptionsFromCLI(args);
|
|
|
|
// Process the command switch.
|
|
pea.ProcessCommandSwitch();
|
|
|
|
// Output the log to a text file.
|
|
pea.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();
|
|
}
|
|
}
|
|
}
|