mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
Merge pull request #146 from PepperDash/hotfix/update-debug-file-path-for-vc4
Updates for VC4 DEV
This commit is contained in:
@@ -70,6 +70,11 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public string DeviceReadyResponsePattern { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used when communcating to programs running in VC-4
|
||||
/// </summary>
|
||||
public string RoomId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
|
||||
@@ -69,7 +69,16 @@ namespace PepperDash.Core
|
||||
// Get the assembly version and print it to console and the log
|
||||
GetVersion();
|
||||
|
||||
var msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion);
|
||||
string msg = "";
|
||||
|
||||
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
|
||||
{
|
||||
msg = string.Format("[App {0}] Using PepperDash_Core v{1}", InitialParametersClass.ApplicationNumber, PepperDashCoreVersion);
|
||||
}
|
||||
else if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server)
|
||||
{
|
||||
msg = string.Format("[Room {0}] Using PepperDash_Core v{1}", InitialParametersClass.RoomId, PepperDashCoreVersion);
|
||||
}
|
||||
|
||||
CrestronConsole.PrintLine(msg);
|
||||
|
||||
@@ -367,7 +376,19 @@ namespace PepperDash.Core
|
||||
/// <param name="items">Object parameters</param>
|
||||
public static void Console(uint level, string format, params object[] items)
|
||||
{
|
||||
if (Level >= level)
|
||||
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server)
|
||||
{
|
||||
var logString = string.Format("[level {0}] {1}", level, string.Format(format, items));
|
||||
|
||||
LogError(ErrorLogLevel.Notice, logString);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Level < level)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CrestronConsole.PrintLine("[{0}]App {1}:{2}", DateTime.Now.ToString("HH:mm:ss.fff"), InitialParametersClass.ApplicationNumber,
|
||||
string.Format(format, items));
|
||||
}
|
||||
@@ -448,7 +469,8 @@ namespace PepperDash.Core
|
||||
/// <param name="str"></param>
|
||||
public static void LogError(ErrorLogLevel errorLogLevel, string str)
|
||||
{
|
||||
var msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);
|
||||
|
||||
var msg = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str) : string.Format("Room {0}:{1}", InitialParametersClass.RoomId, str);
|
||||
switch (errorLogLevel)
|
||||
{
|
||||
case ErrorLogLevel.Error:
|
||||
@@ -488,7 +510,11 @@ namespace PepperDash.Core
|
||||
//if (!Directory.Exists(dir))
|
||||
// Directory.Create(dir);
|
||||
|
||||
using (var sw = new StreamWriter(GetMemoryFileName()))
|
||||
var fileName = GetMemoryFileName();
|
||||
|
||||
Console(0, ErrorLogLevel.Notice, "Loading debug settings file from {0}", fileName);
|
||||
|
||||
using (var sw = new StreamWriter(fileName))
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(_contexts);
|
||||
sw.Write(json);
|
||||
@@ -524,11 +550,16 @@ namespace PepperDash.Core
|
||||
/// Helper to get the file path for this app's debug memory
|
||||
/// </summary>
|
||||
static string GetMemoryFileName()
|
||||
{
|
||||
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
|
||||
{
|
||||
CheckForMigration();
|
||||
return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
||||
}
|
||||
|
||||
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
|
||||
}
|
||||
|
||||
private static void CheckForMigration()
|
||||
{
|
||||
var oldFilePath = String.Format(@"\nvram\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
||||
@@ -537,6 +568,11 @@ namespace PepperDash.Core
|
||||
//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}",
|
||||
InitialParametersClass.ApplicationNumber));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user