diff --git a/src/Pepperdash Core/Logging/Debug.cs b/src/Pepperdash Core/Logging/Debug.cs index d711bcb..1fea4c8 100644 --- a/src/Pepperdash Core/Logging/Debug.cs +++ b/src/Pepperdash Core/Logging/Debug.cs @@ -64,13 +64,13 @@ namespace PepperDash.Core /// Describes the folder location where a given program stores it's debug level memory. By default, the /// file written will be named appNdebug where N is 1-10. /// - public static string OldFilePathPrefix = @"\nvram\debug\"; + public static string OldFilePathPrefix = "/nvram/debug/"; /// /// Describes the new folder location where a given program stores it's debug level memory. By default, the /// file written will be named appNdebug where N is 1-10. /// - public static string NewFilePathPrefix = @"\user\debug\"; + public static string NewFilePathPrefix = "/user/debug/"; /// /// The name of the file containing the current debug settings. @@ -823,9 +823,8 @@ namespace PepperDash.Core { if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) { - // Make sure the path starts with a slash to make it absolute - return String.Format("/user/debugSettings/program{0}", InitialParametersClass.ApplicationNumber); - } + return "/user/debugSettings/program" + InitialParametersClass.ApplicationNumber; + } return string.Format("{0}{1}user{1}debugSettings{1}{2}.json", Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId); @@ -833,41 +832,42 @@ namespace PepperDash.Core private static void CheckForMigration() { - var oldFilePath = String.Format(@"\nvram\debugSettings\program{0}", InitialParametersClass.ApplicationNumber); - var newFilePath = String.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber); + var oldFilePath = String.Format("/nvram/debugSettings/program{0}", InitialParametersClass.ApplicationNumber); + var newFilePath = String.Format("/user/debugSettings/program{0}", InitialParametersClass.ApplicationNumber); //check for file at old path if (!File.Exists(oldFilePath)) { Console(0, ErrorLogLevel.Notice, String.Format( - @"Debug settings file migration not necessary. Using file at \user\debugSettings\program{0}", + "Debug settings file migration not necessary. Using file at /user/debugSettings/program{0}", InitialParametersClass.ApplicationNumber)); return; } //create the new directory if it doesn't already exist - if (!Directory.Exists(@"\user\debugSettings")) + if (!Directory.Exists("/user/debugSettings")) { - Directory.CreateDirectory(@"\user\debugSettings"); + Directory.CreateDirectory("/user/debugSettings"); } Console(0, ErrorLogLevel.Notice, String.Format( - @"File found at \nvram\debugSettings\program{0}. Migrating to \user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber)); + "File found at /nvram/debugSettings/program{0}. Migrating to /user/debugSettings/program{0}", + InitialParametersClass.ApplicationNumber)); //Copy file from old path to new path, then delete it. This will overwrite the existing file File.Copy(oldFilePath, newFilePath, true); File.Delete(oldFilePath); //Check if the old directory is empty, then delete it if it is - if (Directory.GetFiles(@"\nvram\debugSettings").Length > 0) + if (Directory.GetFiles("/nvram/debugSettings").Length > 0) { return; } - Directory.Delete(@"\nvram\debugSettings"); + Directory.Delete("/nvram/debugSettings"); } /// diff --git a/src/Pepperdash Core/Logging/DebugCrestronLoggerSink.cs b/src/Pepperdash Core/Logging/DebugCrestronLoggerSink.cs index 0814453..6e3e152 100644 --- a/src/Pepperdash Core/Logging/DebugCrestronLoggerSink.cs +++ b/src/Pepperdash Core/Logging/DebugCrestronLoggerSink.cs @@ -2,6 +2,7 @@ using Crestron.SimplSharp.CrestronLogger; using Serilog.Core; using Serilog.Events; +using System; // Add this for Exception class namespace PepperDash.Core.Logging { @@ -23,7 +24,22 @@ namespace PepperDash.Core.Logging public DebugCrestronLoggerSink() { - CrestronLogger.Initialize(1, LoggerModeEnum.RM); + try + { + // The Crestron SDK appears to be using Windows-style paths internally + // We'll wrap this in a try/catch to handle path errors + + CrestronLogger.Initialize(1, LoggerModeEnum.DEFAULT); + } + catch (Crestron.SimplSharp.CrestronIO.InvalidDirectoryLocationException ex) + { + // Log the error but allow the application to continue without the RM logger + CrestronConsole.PrintLine("Error initializing CrestronLogger in RM mode: {0}", ex.Message); + + // Just report the error and continue - don't try to use other logger modes + // since LoggerModeEnum doesn't have a Default value + CrestronConsole.PrintLine("CrestronLogger will not be available"); + } } } -} +} \ No newline at end of file