logging, map path fix

This commit is contained in:
Bitl 2020-07-14 17:28:34 -07:00
parent b1513d8e5d
commit fbe0ef730d
14 changed files with 110 additions and 0 deletions

View File

@ -1,5 +1,8 @@
#region Usings
using NLog;
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
#endregion
@ -14,6 +17,18 @@ namespace Novetus.ClientScriptTester
[STAThread]
static void Main(string[] args)
{
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = Assembly.GetExecutingAssembly().Location + "\\Tester-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile);
LogManager.Configuration = config;
//https://stackify.com/csharp-catch-all-exceptions/
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
Logger log = LogManager.GetCurrentClassLogger();
log.Error(eventArgs.Exception);
};
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

View File

@ -34,9 +34,16 @@
<ApplicationIcon>NovetusIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -69,6 +76,7 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.7.2" targetFramework="net40" />
</packages>

View File

@ -91,7 +91,11 @@
<Reference Include="Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b, processorArchitecture=MSIL">
<HintPath>..\packages\Trove.Nini.1.1.0.0\lib\net20\Nini.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@ -109,10 +113,13 @@
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />

View File

@ -4,6 +4,7 @@ using Mono.Nat;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using NLog;
#endregion
namespace NovetusCMD
@ -155,6 +156,18 @@ namespace NovetusCMD
#region Main Program Function
public static void Main(string[] args)
{
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\CMD-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile);
LogManager.Configuration = config;
//https://stackify.com/csharp-catch-all-exceptions/
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
Logger log = LogManager.GetCurrentClassLogger();
log.Error(eventArgs.Exception);
};
if (args.Length > 0)
{
CommandLineArguments.Arguments CommandLine = new CommandLineArguments.Arguments(args);

View File

@ -4,5 +4,6 @@
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net40" />
<package id="NLog" version="4.7.2" targetFramework="net40" />
<package id="Trove.Nini" version="1.1.0.0" targetFramework="net40" />
</packages>

View File

@ -1,5 +1,6 @@
#region Usings
using Nini.Config;
using NLog;
using System;
using System.Diagnostics;
using System.Drawing;
@ -1177,26 +1178,34 @@ public class GlobalFuncs
box.AppendText("[" + DateTime.Now.ToShortTimeString() + "] - ", Color.White);
Logger log = LogManager.GetCurrentClassLogger();
switch (type)
{
case 2:
box.AppendText(text, Color.Red);
log.Error(text);
break;
case 3:
box.AppendText(text, Color.Lime);
log.Info(text);
break;
case 4:
box.AppendText(text, Color.Aqua);
log.Info(text);
break;
case 5:
box.AppendText(text, Color.Yellow);
log.Warn(text);
break;
case 6:
box.AppendText(text, Color.LightSalmon);
log.Info(text);
break;
case 1:
default:
box.AppendText(text, Color.White);
log.Info(text);
break;
}
@ -1210,23 +1219,30 @@ public class GlobalFuncs
ConsoleText("[" + DateTime.Now.ToShortTimeString() + "] - ", ConsoleColor.White);
}
Logger log = LogManager.GetCurrentClassLogger();
switch (type)
{
case 2:
ConsoleText(text, ConsoleColor.Red);
log.Error(text);
break;
case 3:
ConsoleText(text, ConsoleColor.Green);
log.Info(text);
break;
case 4:
ConsoleText(text, ConsoleColor.Cyan);
log.Info(text);
break;
case 5:
ConsoleText(text, ConsoleColor.Yellow);
log.Warn(text);
break;
case 1:
default:
ConsoleText(text, ConsoleColor.White);
log.Info(text);
break;
}

View File

@ -76,6 +76,7 @@
<Reference Include="DotNetZip, Version=1.11.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
@ -94,7 +95,11 @@
<Reference Include="Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b, processorArchitecture=MSIL">
<HintPath>..\packages\Trove.Nini.1.1.0.0\lib\net20\Nini.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
@ -112,10 +117,13 @@
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />

View File

@ -1,5 +1,7 @@
#region Usings
using NLog;
using System;
using System.IO;
using System.Windows.Forms;
#endregion
@ -14,6 +16,18 @@ namespace NovetusLauncher
[STAThread]
private static void Main(string[] args)
{
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\Launcher-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile);
LogManager.Configuration = config;
//https://stackify.com/csharp-catch-all-exceptions/
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
Logger log = LogManager.GetCurrentClassLogger();
log.Error(eventArgs.Exception);
};
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

View File

@ -5,5 +5,6 @@
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net40" />
<package id="NLog" version="4.7.2" targetFramework="net40" />
<package id="Trove.Nini" version="1.1.0.0" targetFramework="net40" />
</packages>

View File

@ -59,7 +59,11 @@
<Reference Include="Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b, processorArchitecture=MSIL">
<HintPath>..\packages\Trove.Nini.1.1.0.0\lib\net20\Nini.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
@ -70,10 +74,13 @@
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />

View File

@ -1,5 +1,7 @@
#region Usings
using NLog;
using System;
using System.IO;
using System.Windows.Forms;
#endregion
@ -14,6 +16,18 @@ namespace NovetusURI
[STAThread]
private static void Main(string[] args)
{
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.ConfigDir + "\\URI-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile);
LogManager.Configuration = config;
//https://stackify.com/csharp-catch-all-exceptions/
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
{
Logger log = LogManager.GetCurrentClassLogger();
log.Error(eventArgs.Exception);
};
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
GlobalFuncs.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);

View File

@ -4,5 +4,6 @@
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net40" />
<package id="NLog" version="4.7.2" targetFramework="net40" />
<package id="Trove.Nini" version="1.1.0.0" targetFramework="net40" />
</packages>

View File

@ -50,6 +50,7 @@ IF %M%==4 GOTO MENU
:CLEANJUNK
del /S Novetus\*.pdb
del /S Novetus\*.log
del /s /q Novetus\clients\2007M\content\scripts\CSMPBoot.lua
del /s /q Novetus\clients\2007M-Shaders\content\scripts\CSMPBoot.lua