minor improvements. log folder, wine detection

This commit is contained in:
Bitl 2022-06-02 11:54:02 -07:00
parent 4af2e34f66
commit 8db3c24ef6
7 changed files with 41 additions and 4 deletions

View File

@ -11,6 +11,7 @@ namespace Novetus.Bootstrapper
{
public static readonly string FixedBinDir = GlobalPaths.BasePathLauncher + @"\\bin";
public static readonly string FixedConfigDir = GlobalPaths.BasePathLauncher + @"\\config";
public static readonly string FixedLogDir = GlobalPaths.BasePathLauncher + @"\\logs";
public static readonly string FixedDataDir = FixedBinDir + @"\\data";
#region File Names

View File

@ -1,6 +1,7 @@
#region Usings
using NLog;
using System;
using System.IO;
using System.Windows.Forms;
#endregion
@ -17,8 +18,13 @@ namespace Novetus.Bootstrapper
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Directory.Exists(LocalPaths.FixedLogDir))
{
Directory.CreateDirectory(LocalPaths.FixedLogDir);
}
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = LocalPaths.FixedConfigDir + "\\Bootstrapper-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = LocalPaths.FixedLogDir + "\\Bootstrapper-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRuleForAllLevels(logfile);
LogManager.Configuration = config;

View File

@ -143,8 +143,13 @@ namespace NovetusCMD
_handler += new EventHandler(CloseHandler);
SetConsoleCtrlHandler(_handler, true);
if (!Directory.Exists(GlobalPaths.LogDir))
{
Directory.CreateDirectory(GlobalPaths.LogDir);
}
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" };
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.LogDir + "\\CMD-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRuleForAllLevels(logfile);
LogManager.Configuration = config;

View File

@ -219,6 +219,11 @@ public class GlobalFuncs
if (write)
{
if (IsWineRunning())
{
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Extended;
}
//WRITE
INIFile ini = new INIFile(cfgpath);
@ -2870,5 +2875,13 @@ public class GlobalFuncs
return false;
}
//converted from https://facreationz.wordpress.com/2014/12/11/c-know-if-running-under-wine/
public static bool IsWineRunning()
{
string processName = "winlogon";
var p = Process.GetProcessesByName(processName).Count();
return (p <= 0);
}
}
#endregion

View File

@ -15,6 +15,7 @@ public class GlobalPaths
public static readonly string DataPath = BasePath + @"\\shareddata";
public static readonly string BinDir = BasePath + @"\\bin";
public static readonly string ConfigDir = BasePath + @"\\config";
public static readonly string LogDir = BasePath + @"\\logs";
public static readonly string ConfigDirClients = ConfigDir + @"\\clients";
public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates";
public static readonly string DataDir = BinDir + @"\\data";

View File

@ -1,6 +1,7 @@
#region Usings
using NLog;
using System;
using System.IO;
#endregion
namespace NovetusLauncher
@ -17,8 +18,13 @@ namespace NovetusLauncher
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
if (!Directory.Exists(GlobalPaths.LogDir))
{
Directory.CreateDirectory(GlobalPaths.LogDir);
}
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" };
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.LogDir + "\\Launcher-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRuleForAllLevels(logfile);
LogManager.Configuration = config;

View File

@ -20,8 +20,13 @@ namespace NovetusURI
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Directory.Exists(GlobalPaths.LogDir))
{
Directory.CreateDirectory(GlobalPaths.LogDir);
}
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" };
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = GlobalPaths.LogDir + "\\URI-log-" + DateTime.Today.ToString("MM-dd-yyyy") + ".log" };
config.AddRuleForAllLevels(logfile);
LogManager.Configuration = config;