diff --git a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs index 68859760..b4bef5b8 100644 --- a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs +++ b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs @@ -12,6 +12,7 @@ using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; //using PepperDash.Essentials.Devices.Common.Cameras; @@ -32,7 +33,7 @@ namespace PepperDash.Essentials.Core.Bridges if (bridge == null) { - Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); + Debug.LogMessage(LogEventLevel.Information, "Unable to find advanced bridge with key: '{0}'", bridgeKey); return; } @@ -58,7 +59,7 @@ namespace PepperDash.Essentials.Core.Bridges if (bridge == null) { - Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); + Debug.LogMessage(LogEventLevel.Information, "Unable to find advanced bridge with key: '{0}'", bridgeKey); return; } @@ -148,11 +149,11 @@ namespace PepperDash.Essentials.Core.Bridges private void LinkDevices() { - Debug.Console(1, this, "Linking Devices..."); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking Devices..."); if (PropertiesConfig.Devices == null) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No devices linked to this bridge"); + Debug.LogMessage(LogEventLevel.Debug, this, "No devices linked to this bridge"); return; } @@ -165,11 +166,11 @@ namespace PepperDash.Essentials.Core.Bridges continue; } - Debug.Console(1, this, "Linking Device: '{0}'", device.Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking Device: '{0}'", device.Key); if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, + Debug.LogMessage(LogEventLevel.Information, this, "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", device.Key); continue; @@ -194,20 +195,20 @@ namespace PepperDash.Essentials.Core.Bridges if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) { - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult); + Debug.LogMessage(LogEventLevel.Verbose, this, "Registration result: {0}", registerResult); return; } - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful"); + Debug.LogMessage(LogEventLevel.Debug, this, "EISC registration successful"); } public void LinkRooms() { - Debug.Console(1, this, "Linking Rooms..."); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking Rooms..."); if (PropertiesConfig.Rooms == null) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No rooms linked to this bridge."); + Debug.LogMessage(LogEventLevel.Debug, this, "No rooms linked to this bridge."); return; } @@ -217,7 +218,7 @@ namespace PepperDash.Essentials.Core.Bridges if (rm == null) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, + Debug.LogMessage(LogEventLevel.Debug, this, "Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey); continue; } @@ -239,7 +240,7 @@ namespace PepperDash.Essentials.Core.Bridges } else { - Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); + Debug.LogMessage(LogEventLevel.Verbose, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); } } @@ -248,11 +249,11 @@ namespace PepperDash.Essentials.Core.Bridges /// public virtual void PrintJoinMaps() { - Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); foreach (var joinMap in JoinMaps) { - Debug.Console(0, "Join map for device '{0}':", joinMap.Key); + Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}':", joinMap.Key); joinMap.Value.PrintJoinMapInfo(); } } @@ -261,11 +262,11 @@ namespace PepperDash.Essentials.Core.Bridges /// public virtual void MarkdownForBridge(string bridgeKey) { - Debug.Console(0, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X")); foreach (var joinMap in JoinMaps) { - Debug.Console(0, "Generating markdown for device '{0}':", joinMap.Key); + Debug.LogMessage(LogEventLevel.Information, "Generating markdown for device '{0}':", joinMap.Key); joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey); } } @@ -280,11 +281,11 @@ namespace PepperDash.Essentials.Core.Bridges if (joinMap == null) { - Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); return; } - Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); + Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); joinMap.PrintJoinMapInfo(); } /// @@ -297,11 +298,11 @@ namespace PepperDash.Essentials.Core.Bridges if (joinMap == null) { - Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); return; } - Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); + Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey); } @@ -322,11 +323,11 @@ namespace PepperDash.Essentials.Core.Bridges var uo = Eisc.BooleanOutput[join].UserObject as Action; if (uo != null) { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); uo(Convert.ToBoolean(state)); } else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); + Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); break; } case "analog": @@ -334,34 +335,34 @@ namespace PepperDash.Essentials.Core.Bridges var uo = Eisc.BooleanOutput[join].UserObject as Action; if (uo != null) { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); uo(Convert.ToUInt16(state)); } else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); break; + Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); break; } case "serial": { var uo = Eisc.BooleanOutput[join].UserObject as Action; if (uo != null) { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); uo(Convert.ToString(state)); } else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); + Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); break; } default: { - Debug.Console(2, "Unknown join type. Use digital/serial/analog"); + Debug.LogMessage(LogEventLevel.Verbose, "Unknown join type. Use digital/serial/analog"); break; } } } catch (Exception e) { - Debug.Console(1, this, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); } } @@ -375,12 +376,12 @@ namespace PepperDash.Essentials.Core.Bridges { try { - Debug.Console(2, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + Debug.LogMessage(LogEventLevel.Verbose, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); var uo = args.Sig.UserObject; if (uo == null) return; - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "Executing Action: {0}", uo.ToString()); if (uo is Action) (uo as Action)(args.Sig.BoolValue); else if (uo is Action) @@ -390,7 +391,7 @@ namespace PepperDash.Essentials.Core.Bridges } catch (Exception e) { - Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error in Eisc_SigChange handler: {0}", e); } } @@ -448,7 +449,7 @@ namespace PepperDash.Essentials.Core.Bridges public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EiscApiAdvanced Device"); var controlProperties = CommFactory.GetControlPropertiesConfig(dc); @@ -478,7 +479,7 @@ namespace PepperDash.Essentials.Core.Bridges { if (string.IsNullOrEmpty(controlProperties.RoomId)) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); + Debug.LogMessage(LogEventLevel.Information, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); eisc = null; break; } diff --git a/src/PepperDash.Essentials.Core/Comm and IR/CecPortController.cs b/src/PepperDash.Essentials.Core/Comm and IR/CecPortController.cs index 203c2f1a..544a682f 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/CecPortController.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/CecPortController.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DM; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -49,7 +50,7 @@ namespace PepperDash.Essentials.Core OnDataReceived(cecDevice.Received.StringValue); else if (args.EventId == CecEventIds.ErrorFeedbackEventId) if(cecDevice.ErrorFeedback.BoolValue) - Debug.Console(2, this, "CEC NAK Error"); + Debug.LogMessage(LogEventLevel.Verbose, this, "CEC NAK Error"); } void OnDataReceived(string s) @@ -59,14 +60,14 @@ namespace PepperDash.Essentials.Core { var bytes = Encoding.GetEncoding(28591).GetBytes(s); if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); + Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); } var textHandler = TextReceived; if (textHandler != null) { if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Received: '{0}'", s); + Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s); textHandler(this, new GenericCommMethodReceiveTextArgs(s)); } } @@ -78,7 +79,7 @@ namespace PepperDash.Essentials.Core if (Port == null) return; if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text); + Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text); Port.StreamCec.Send.StringValue = text; } @@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Core return; var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); Port.StreamCec.Send.StringValue = text; } diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs b/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs index 6d454ac5..679420d3 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -43,7 +44,7 @@ namespace PepperDash.Essentials.Core { if (port == null) { - Debug.Console(0, this, "ERROR: Invalid com port, continuing but comms will not function"); + Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function"); return; } @@ -58,7 +59,7 @@ namespace PepperDash.Essentials.Core { if (Port == null) { - Debug.Console(0,this,Debug.ErrorLogLevel.Error, "Configured com Port for this device does not exist."); + Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist."); return; } if (Port.Parent is CrestronControlSystem) @@ -66,7 +67,7 @@ namespace PepperDash.Essentials.Core var result = Port.Register(); if (result != eDeviceRegistrationUnRegistrationResponse.Success) { - Debug.Console(0, this, "ERROR: Cannot register Com port: {0}", result); + Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Com port: {0}", result); return; // false } } @@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core var specResult = Port.SetComPortSpec(Spec); if (specResult != 0) { - Debug.Console(0, this, "WARNING: Cannot set comspec"); + Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Cannot set comspec"); return; } Port.SerialDataReceived += Port_SerialDataReceived; @@ -98,14 +99,14 @@ namespace PepperDash.Essentials.Core { var bytes = Encoding.GetEncoding(28591).GetBytes(s); if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); + Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); } var textHandler = TextReceived; if (textHandler != null) { if (StreamDebugging.RxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Received: '{0}'", s); + Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s); textHandler(this, new GenericCommMethodReceiveTextArgs(s)); } } @@ -123,7 +124,7 @@ namespace PepperDash.Essentials.Core return; if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text); + Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text); Port.Send(text); } @@ -133,7 +134,7 @@ namespace PepperDash.Essentials.Core return; var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); if (StreamDebugging.TxStreamDebuggingIsEnabled) - Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); Port.Send(text); } diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs index f13e6375..62296bd8 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs @@ -76,7 +76,7 @@ namespace PepperDash.Essentials.Core public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - //Debug.Console(2, "ReadJson type: " + objectType.Name); + //Debug.LogMessage(LogEventLevel.Verbose, "ReadJson type: " + objectType.Name); if (objectType == typeof(ComPort.eComBaudRates)) return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false); else if (objectType == typeof(ComPort.eComDataBits)) diff --git a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs index f7b743cc..f54f4bfd 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -22,12 +23,12 @@ namespace PepperDash.Essentials.Core { return JsonConvert.DeserializeObject (deviceConfig.Properties["control"].ToString()); - //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); + //Debug.LogMessage(LogEventLevel.Verbose, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); } catch (Exception e) { - Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); + Debug.LogMessage(LogEventLevel.Information, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); return null; } } @@ -98,7 +99,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", + Debug.LogMessage(LogEventLevel.Information, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", deviceConfig.Properties.ToString(), e); } @@ -115,7 +116,7 @@ namespace PepperDash.Essentials.Core var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey); if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts) return dev.ComPorts[config.ControlPortNumber]; - Debug.Console(0,Debug.ErrorLogLevel.Notice, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); return null; } @@ -130,7 +131,7 @@ namespace PepperDash.Essentials.Core { var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); - Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null + Debug.LogMessage(LogEventLevel.Information, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null ? "is not valid, failed to get cec port" : "found in device manager, attempting to get cec port"); @@ -139,7 +140,7 @@ namespace PepperDash.Essentials.Core if (String.IsNullOrEmpty(config.ControlPortName)) { - Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); + Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); return null; } @@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core var inputsOutputs = dev as IRoutingInputsOutputs; if (inputsOutputs == null) { - Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", + Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", config.ControlPortDevKey, config.ControlPortName); return null; @@ -164,13 +165,13 @@ namespace PepperDash.Essentials.Core } catch (Exception ex) { - Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message); - Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Debug, "GetCecPort Exception Message: {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Verbose, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); if (ex.InnerException != null) - Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException); + Debug.LogMessage(LogEventLevel.Information, "GetCecPort Exception InnerException: {0}", ex.InnerException); } - Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", + Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", config.ControlPortDevKey, config.ControlPortName); return null; @@ -191,7 +192,7 @@ namespace PepperDash.Essentials.Core { var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts; if (dev == null) - Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey); + Debug.LogMessage(LogEventLevel.Information, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey); return dev; } } @@ -205,9 +206,7 @@ namespace PepperDash.Essentials.Core { [JsonConverter(typeof(ComSpecJsonConverter))] - public ComPort.ComPortSpec ComParams { get; set; } - - public string RoomId { get; set; } + public ComPort.ComPortSpec ComParams { get; set; } public string CresnetId { get; set; } diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs index db06d2aa..fd7184aa 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -39,7 +40,7 @@ namespace PepperDash.Essentials.Core public override bool CustomActivate() { Communication.Connect(); - CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; + CommunicationMonitor.StatusChange += (o, a) => { Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; CommunicationMonitor.Start(); CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator); @@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Core void SendLine(string s) { //if (Debug.Level == 2) - // Debug.Console(2, this, " Send '{0}'", ComTextHelper.GetEscapedText(s)); + // Debug.LogMessage(LogEventLevel.Verbose, this, " Send '{0}'", ComTextHelper.GetEscapedText(s)); Communication.SendText(s + LineEnding); } } @@ -75,7 +76,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Comm Mock Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Comm Mock Device"); var comm = CommFactory.CreateCommForDevice(dc); var props = Newtonsoft.Json.JsonConvert.DeserializeObject( dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs index 8e00e5c1..ddd7ec5d 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs @@ -10,6 +10,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core public static IKeyed BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device"); return new GenericComm(dc); } @@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(2, this, "Error deserializing port config: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error deserializing port config: {0}", e); } } @@ -85,16 +86,16 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } if (CommPort == null) { - Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. CommPort is null", Key); return; } - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // this is a permanent event handler. This cannot be -= from event CommPort.TextReceived += (s, a) => @@ -137,7 +138,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device"); return new GenericComm(dc); } } diff --git a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs index 7141613b..498df9d2 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -40,7 +41,7 @@ namespace PepperDash.Essentials.Core return null; if (control["method"].Value() != "ir") { - Debug.Console(0, "IRPortHelper called with non-IR properties"); + Debug.LogMessage(LogEventLevel.Information, "IRPortHelper called with non-IR properties"); return null; } @@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Core var portNum = control.Value("controlPortNumber"); if (portDevKey == null || portNum == 0) { - Debug.Console(1, "WARNING: Properties is missing port device or port number"); + Debug.LogMessage(LogEventLevel.Debug, "WARNING: Properties is missing port device or port number"); return port; } @@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core if (irDev == null) { - Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey); + Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device with IR ports '{0}' not found", portDevKey); return port; } @@ -76,7 +77,7 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range", + Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device '{0}' IR port {1} out of range", portDevKey, portNum); return port; } @@ -87,14 +88,14 @@ namespace PepperDash.Essentials.Core var irControllerKey = dc.Key + "-ir"; if (dc.Properties == null) { - Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key); + Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key); return null; } var control = dc.Properties["control"]; if (control == null) { - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, "WARNING: Device config does not include control properties. IR will not function for {0}", dc.Key); return null; } @@ -105,13 +106,13 @@ namespace PepperDash.Essentials.Core if (portDevKey == null) { - Debug.Console(0, "WARNING: control properties is missing ir device for {0}", dc.Key); + Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir device for {0}", dc.Key); return null; } if (portNum == 0) { - Debug.Console(0, "WARNING: control properties is missing ir port number for {0}", dc.Key); + Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir port number for {0}", dc.Key); return null; } @@ -123,12 +124,12 @@ namespace PepperDash.Essentials.Core if (irDev == null) { - Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey); + Debug.LogMessage(LogEventLevel.Information, "WARNING: device with IR ports '{0}' not found", portDevKey); return null; } if (portNum > irDev.NumberOfIROutputPorts) { - Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range", + Debug.LogMessage(LogEventLevel.Information, "WARNING: device '{0}' IR port {1} out of range", portDevKey, portNum); return null; } @@ -143,7 +144,7 @@ namespace PepperDash.Essentials.Core public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) { - Debug.Console(1, "Attempting to create new Ir Port Controller"); + Debug.LogMessage(LogEventLevel.Debug, "Attempting to create new Ir Port Controller"); if (config == null) { @@ -165,7 +166,7 @@ namespace PepperDash.Essentials.Core var irControllerKey = devConf.Key + "-ir"; if (devConf.Properties == null) { - Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); + Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); return new IrOutputPortController(irControllerKey, null, ""); } @@ -173,7 +174,7 @@ namespace PepperDash.Essentials.Core if (control == null) { var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function"); + Debug.LogMessage(LogEventLevel.Information, c, "WARNING: Device config does not include control properties. IR will not function"); return c; } @@ -184,14 +185,14 @@ namespace PepperDash.Essentials.Core if (portDevKey == null) { var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir device"); + Debug.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir device"); return c; } if (portNum == 0) { var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir port number"); + Debug.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir port number"); return c; } @@ -204,7 +205,7 @@ namespace PepperDash.Essentials.Core if (irDev == null) { var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey); + Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device with IR ports '{0}' not found", portDevKey); return c; } @@ -214,7 +215,7 @@ namespace PepperDash.Essentials.Core else { var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range", + Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device '{0}' IR port {1} out of range", portDevKey, portNum); return c; } diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigReader.cs b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigReader.cs index 9cdd3e98..8549ecd8 100644 --- a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigReader.cs +++ b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigReader.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core.Config { @@ -27,7 +28,7 @@ namespace PepperDash.Essentials.Core.Config public static bool LoadConfig2() { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file."); + Debug.LogMessage(LogEventLevel.Information, "Loading unmerged system/template portal configuration file."); try { // Check for local config file first @@ -35,7 +36,7 @@ namespace PepperDash.Essentials.Core.Config bool localConfigFound = false; - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Attempting to load Local config file: '{0}'", filePath); // Check for local config directory first @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Config { if (configFiles.Length > 1) { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****"); return false; } @@ -57,7 +58,7 @@ namespace PepperDash.Essentials.Core.Config } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, + Debug.LogMessage(LogEventLevel.Information, "Local Configuration file not present.", filePath); } @@ -67,33 +68,33 @@ namespace PepperDash.Essentials.Core.Config { filePath = Global.FilePathPrefix + Global.ConfigFileName; - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Attempting to load Portal config file: '{0}'", filePath); configFiles = GetConfigFiles(filePath); if (configFiles != null) { - Debug.Console(2, "{0} config files found matching pattern", configFiles.Length); + Debug.LogMessage(LogEventLevel.Verbose, "{0} config files found matching pattern", configFiles.Length); if (configFiles.Length > 1) { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****"); return false; } else if (configFiles.Length == 1) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Found Portal config file: '{0}'", filePath); } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No config file found."); + Debug.LogMessage(LogEventLevel.Information, "No config file found."); return false; } } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "ERROR: Portal Configuration file not present. Please load file and reset program."); return false; } @@ -111,13 +112,13 @@ namespace PepperDash.Essentials.Core.Config // Read the file using (StreamReader fs = new StreamReader(filePath)) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Loading config file: '{0}'", filePath); if (localConfigFound) { ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config"); + Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Local Config"); return true; } @@ -139,14 +140,14 @@ namespace PepperDash.Essentials.Core.Config } } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config"); + Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config"); return true; } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "ERROR: Config load failed: \r{0}", e); return false; } } @@ -163,20 +164,20 @@ namespace PepperDash.Essentials.Core.Config if (Directory.Exists(dir)) { - Debug.Console(1, "Searching in Directory '{0}'", dir); + Debug.LogMessage(LogEventLevel.Debug, "Searching in Directory '{0}'", dir); // Get the directory info var dirInfo = new DirectoryInfo(dir); // Get the file name var fileName = Path.GetFileName(filePath); - Debug.Console(1, "For Config Files matching: '{0}'", fileName); + Debug.LogMessage(LogEventLevel.Debug, "For Config Files matching: '{0}'", fileName); // Get the files that match from the directory return dirInfo.GetFiles(fileName); } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, + Debug.LogMessage(LogEventLevel.Information, "Directory not found: ", dir); return null; @@ -248,8 +249,8 @@ namespace PepperDash.Essentials.Core.Config // Line 8 .Append(new string('*', debugStringWidth)); - Debug.Console(2, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath); - Debug.Console(0, newDebugString.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, "Found Local config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, newDebugString.ToString()); } } diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs index 13641a80..141ffc25 100644 --- a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs +++ b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs @@ -12,6 +12,7 @@ using Crestron.SimplSharp.Net.Http; using Crestron.SimplSharpPro.Diagnostics; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Config { @@ -21,7 +22,7 @@ namespace PepperDash.Essentials.Core.Config public static void GetConfigFromServer(string url) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to get new config from '{0}'", url); + Debug.LogMessage(LogEventLevel.Information, "Attempting to get new config from '{0}'", url); // HTTP GET var req = new HttpClientRequest(); @@ -51,17 +52,17 @@ namespace PepperDash.Essentials.Core.Config } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code); + Debug.LogMessage(LogEventLevel.Information, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code); OnStatusUpdate(eUpdateStatus.UpdateFailed); } } else - Debug.Console(0, Debug.ErrorLogLevel.Error, "Request for config from Server Failed: {0}", e); + Debug.LogMessage(LogEventLevel.Information, "Request for config from Server Failed: {0}", e); }); } catch (Exception e) { - Debug.Console(1, "Error Getting Config from Server: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, "Error Getting Config from Server: {0}", e); } } @@ -90,7 +91,7 @@ namespace PepperDash.Essentials.Core.Config } catch (Exception e) { - Debug.Console(1, "Error parsing new config: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, "Error parsing new config: {0}", e); OnStatusUpdate(eUpdateStatus.UpdateFailed); } @@ -107,7 +108,7 @@ namespace PepperDash.Essentials.Core.Config if (configFiles != null) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Existing config files found. Moving to Archive folder."); + Debug.LogMessage(LogEventLevel.Information, "Existing config files found. Moving to Archive folder."); OnStatusUpdate(eUpdateStatus.ArchivingConfigs); @@ -115,7 +116,7 @@ namespace PepperDash.Essentials.Core.Config } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No Existing config files found in '{0}'. Nothing to archive", filePath); + Debug.LogMessage(LogEventLevel.Information, "No Existing config files found in '{0}'. Nothing to archive", filePath); } } @@ -140,12 +141,12 @@ namespace PepperDash.Essentials.Core.Config if(archivedConfigFiles != null || archivedConfigFiles.Length > 0) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length); + Debug.LogMessage(LogEventLevel.Information, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length); for (int i = 0; i < archivedConfigFiles.Length; i++ ) { var file = archivedConfigFiles[i]; - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Deleting archived file: '{0}'", file.FullName); + Debug.LogMessage(LogEventLevel.Information, "Deleting archived file: '{0}'", file.FullName); file.Delete(); } } @@ -155,7 +156,7 @@ namespace PepperDash.Essentials.Core.Config // Move any files from the program folder to the archive folder foreach (var file in files) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Moving config file '{0}' to archive folder", file.FullName); + Debug.LogMessage(LogEventLevel.Information, "Moving config file '{0}' to archive folder", file.FullName); // Moves the file and appends the .bak extension var fileDest = archiveDirectoryPath + "/" + file.Name + ".bak"; @@ -164,7 +165,7 @@ namespace PepperDash.Essentials.Core.Config file.MoveTo(fileDest); } else - Debug.Console(0, Debug.ErrorLogLevel.Warning, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest); + Debug.LogMessage(LogEventLevel.Information, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest); } } @@ -179,7 +180,7 @@ namespace PepperDash.Essentials.Core.Config { OnStatusUpdate(eUpdateStatus.DeletingLocalConfig); Directory.Delete(folderPath); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Local Config Found in '{0}'. Deleting.", folderPath); + Debug.LogMessage(LogEventLevel.Information, "Local Config Found in '{0}'. Deleting.", folderPath); } } @@ -188,7 +189,7 @@ namespace PepperDash.Essentials.Core.Config /// static void RestartProgram() { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to Reset Program"); + Debug.LogMessage(LogEventLevel.Information, "Attempting to Reset Program"); OnStatusUpdate(eUpdateStatus.RestartingProgram); @@ -196,7 +197,7 @@ namespace PepperDash.Essentials.Core.Config CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response); - Debug.Console(1, "Console Response: {0}", response); + Debug.LogMessage(LogEventLevel.Debug, "Console Response: {0}", response); } } diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigWriter.cs b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigWriter.cs index 8c1e8f10..58ced97e 100644 --- a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigWriter.cs +++ b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigWriter.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharp.CrestronIO; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Config { @@ -42,7 +43,7 @@ namespace PepperDash.Essentials.Core.Config // Replace the current properties JToken with the new one passed into this method deviceConfig.Properties = properties; - Debug.Console(1, "Updated properties of device: '{0}'", deviceKey); + Debug.LogMessage(LogEventLevel.Debug, "Updated properties of device: '{0}'", deviceKey); success = true; } @@ -62,7 +63,7 @@ namespace PepperDash.Essentials.Core.Config { ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config; - Debug.Console(1, "Updated config of device: '{0}'", config.Key); + Debug.LogMessage(LogEventLevel.Debug, "Updated config of device: '{0}'", config.Key); success = true; } @@ -82,7 +83,7 @@ namespace PepperDash.Essentials.Core.Config { ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config; - Debug.Console(1, "Updated room of device: '{0}'", config.Key); + Debug.LogMessage(LogEventLevel.Debug, "Updated room of device: '{0}'", config.Key); success = true; } @@ -102,7 +103,7 @@ namespace PepperDash.Essentials.Core.Config WriteTimer.Reset(WriteTimeout); - Debug.Console(1, "Config File write timer has been reset."); + Debug.LogMessage(LogEventLevel.Debug, "Config File write timer has been reset."); } /// @@ -128,9 +129,9 @@ namespace PepperDash.Essentials.Core.Config if (WriteTimer != null) WriteTimer.Stop(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file"); + Debug.LogMessage(LogEventLevel.Information, "Writing Configuration to file"); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Attempting to write config file: '{0}'", filePath); try { @@ -144,12 +145,12 @@ namespace PepperDash.Essentials.Core.Config } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock"); + Debug.LogMessage(LogEventLevel.Information, "Unable to enter FileLock"); } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: Config write failed: \r{0}", e); } finally { diff --git a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs index 9d8ebe3d..9669ca43 100644 --- a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs +++ b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs @@ -5,6 +5,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Core.JsonStandardObjects; using PepperDash.Essentials.Core.Bridges; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -65,17 +66,17 @@ namespace PepperDash.Essentials.Core /// public override bool CustomActivate() { - Debug.Console(0, this, "Activating"); + Debug.LogMessage(LogEventLevel.Information, this, "Activating"); if (!PreventRegistration) { - //Debug.Console(1, this, " Does not require registration. Skipping"); + //Debug.LogMessage(LogEventLevel.Debug, this, " Does not require registration. Skipping"); if (Hardware.Registerable && !Hardware.Registered) { var response = Hardware.RegisterWithLogging(Key); if (response != eDeviceRegistrationUnRegistrationResponse.Success) { - //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); + //Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); return false; } } @@ -141,7 +142,7 @@ namespace PepperDash.Essentials.Core void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { - Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); + Debug.LogMessage(LogEventLevel.Verbose, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); if (!Hardware.Registered) { @@ -198,12 +199,11 @@ namespace PepperDash.Essentials.Core public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key) { var result = device.Register(); - var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? - Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; - Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); + + Debug.LogMessage(LogEventLevel.Information, "Register device result: '{0}', type '{1}', result {2}", key, device, result); //if (result != eDeviceRegistrationUnRegistrationResponse.Success) //{ - // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); + // Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result); //} return result; } diff --git a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs.orig b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs.orig index 416cc553..bef4ae01 100644 --- a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs.orig +++ b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs.orig @@ -38,16 +38,16 @@ namespace PepperDash.Essentials.Core /// public override bool CustomActivate() { - Debug.Console(0, this, "Activating"); + Debug.LogMessage(LogEventLevel.Information, this, "Activating"); var response = Hardware.RegisterWithLogging(Key); if (response != eDeviceRegistrationUnRegistrationResponse.Success) { <<<<<<< HEAD - Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); + Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); return false; } ======= - Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); + Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); return false; } >>>>>>> origin/feature/ecs-342-neil @@ -119,7 +119,7 @@ namespace PepperDash.Essentials.Core var result = device.Register(); if (result != eDeviceRegistrationUnRegistrationResponse.Success) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); + Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result); } return result; } diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs index 4078c331..a5923011 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core.CrestronIO @@ -67,7 +68,7 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (!Global.ControlSystem.SupportsDigitalInput) { - Debug.Console(0, "GetDigitalInput: Processor does not support Digital Inputs"); + Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Processor does not support Digital Inputs"); return null; } ioPortDevice = Global.ControlSystem; @@ -77,20 +78,20 @@ namespace PepperDash.Essentials.Core.CrestronIO var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts; if (ioPortDev == null) { - Debug.Console(0, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); return null; } ioPortDevice = ioPortDev; } if (ioPortDevice == null) { - Debug.Console(0, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey); return null; } if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts) { - Debug.Console(0, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); } return ioPortDevice.DigitalInputPorts[dc.PortNumber]; @@ -117,20 +118,20 @@ namespace PepperDash.Essentials.Core.CrestronIO } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } try { - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // Link feedback for input state InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]); } catch (Exception e) { - Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); - Debug.Console(1, this, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); } } @@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Digital Input Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Digital Input Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericRelayDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericRelayDevice.cs index b8c580df..2bc2c50b 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericRelayDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericRelayDevice.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core.CrestronIO { @@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.CrestronIO if (RelayOutput == null) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber); return; } @@ -69,7 +70,7 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (!Global.ControlSystem.SupportsRelay) { - Debug.Console(0, "Processor does not support relays"); + Debug.LogMessage(LogEventLevel.Information, "Processor does not support relays"); return null; } relayDevice = Global.ControlSystem; @@ -80,7 +81,7 @@ namespace PepperDash.Essentials.Core.CrestronIO var essentialsDevice = DeviceManager.GetDeviceForKey(dc.PortDeviceKey); if (essentialsDevice == null) { - Debug.Console(0, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey); return null; } @@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Core.CrestronIO if (relayDevice == null) { - Debug.Console(0, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey); return null; } @@ -97,7 +98,7 @@ namespace PepperDash.Essentials.Core.CrestronIO return relayDevice.RelayPorts[dc.PortNumber]; } - Debug.Console(0, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); return null; } @@ -165,16 +166,16 @@ namespace PepperDash.Essentials.Core.CrestronIO } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } if (RelayOutput == null) { - Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Relay is null", Key); return; } - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b => { @@ -202,7 +203,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Relay Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Relay Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportAnalogInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportAnalogInputDevice.cs index a0fbd03d..af83b3d6 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportAnalogInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportAnalogInputDevice.cs @@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core.CrestronIO { @@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core.CrestronIO InputPort.VersiportChange += InputPort_VersiportChange; - Debug.Console(1, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); + Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); }); @@ -76,7 +77,7 @@ namespace PepperDash.Essentials.Core.CrestronIO void InputPort_VersiportChange(Versiport port, VersiportEventArgs args) { - Debug.Console(1, this, "Versiport change: {0}", args.Event); + Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); if(args.Event == eVersiportEvent.AnalogInChange) InputValueFeedback.FireUpdate(); @@ -102,12 +103,12 @@ namespace PepperDash.Essentials.Core.CrestronIO } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } try { - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // Link feedback for input state InputValueFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputValue.JoinNumber]); @@ -117,8 +118,8 @@ namespace PepperDash.Essentials.Core.CrestronIO } catch (Exception e) { - Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); - Debug.Console(1, this, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); } trilist.OnlineStatusChange += (d, args) => @@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (!Global.ControlSystem.SupportsVersiport) { - Debug.Console(0, "GetVersiportAnalogInput: Processor does not support Versiports"); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Processor does not support Versiports"); return null; } ioPortDevice = Global.ControlSystem; @@ -157,25 +158,25 @@ namespace PepperDash.Essentials.Core.CrestronIO var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts; if (ioPortDev == null) { - Debug.Console(0, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey); return null; } ioPortDevice = ioPortDev; } if (ioPortDevice == null) { - Debug.Console(0, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); return null; } if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts) { - Debug.Console(0, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); return null; } if(!ioPortDevice.VersiPorts[dc.PortNumber].SupportsAnalogInput) { - Debug.Console(0, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber); return null; } @@ -196,7 +197,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs index aa25e6b4..5ed1bfa8 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs @@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core.CrestronIO { @@ -53,7 +54,7 @@ namespace PepperDash.Essentials.Core.CrestronIO - Debug.Console(1, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); + Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); }); @@ -61,7 +62,7 @@ namespace PepperDash.Essentials.Core.CrestronIO void InputPort_VersiportChange(Versiport port, VersiportEventArgs args) { - Debug.Console(1, this, "Versiport change: {0}", args.Event); + Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); if(args.Event == eVersiportEvent.DigitalInChange) InputStateFeedback.FireUpdate(); @@ -85,20 +86,20 @@ namespace PepperDash.Essentials.Core.CrestronIO } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } try { - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // Link feedback for input state InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]); } catch (Exception e) { - Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); - Debug.Console(1, this, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); } } @@ -114,7 +115,7 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (!Global.ControlSystem.SupportsVersiport) { - Debug.Console(0, "GetVersiportDigitalInput: Processor does not support Versiports"); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Processor does not support Versiports"); return null; } ioPortDevice = Global.ControlSystem; @@ -124,20 +125,20 @@ namespace PepperDash.Essentials.Core.CrestronIO var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts; if (ioPortDev == null) { - Debug.Console(0, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); return null; } ioPortDevice = ioPortDev; } if (ioPortDevice == null) { - Debug.Console(0, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); return null; } if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts) { - Debug.Console(0, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); } return ioPortDevice.VersiPorts[dc.PortNumber]; @@ -156,7 +157,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportOutputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportOutputDevice.cs index 8dda5bfb..030dc613 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportOutputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportOutputDevice.cs @@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core.CrestronIO { @@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.CrestronIO if (!OutputPort.SupportsDigitalOutput) { - Debug.Console(0, this, "Device does not support configuration as a Digital Output"); + Debug.LogMessage(LogEventLevel.Information, this, "Device does not support configuration as a Digital Output"); return; } @@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core.CrestronIO void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args) { - Debug.Console(1, this, "Versiport change: {0}", args.Event); + Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); if(args.Event == eVersiportEvent.DigitalOutChange) OutputStateFeedback.FireUpdate(); @@ -77,14 +78,14 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (OutputPort.SupportsDigitalOutput) { - Debug.Console(0, this, "Passed the Check"); + Debug.LogMessage(LogEventLevel.Information, this, "Passed the Check"); OutputPort.DigitalOut = state; } else { - Debug.Console(0, this, "Versiport does not support Digital Output Mode"); + Debug.LogMessage(LogEventLevel.Information, this, "Versiport does not support Digital Output Mode"); } } @@ -106,12 +107,12 @@ namespace PepperDash.Essentials.Core.CrestronIO } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } try { - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // Link feedback for input state OutputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OutputState.JoinNumber]); @@ -119,8 +120,8 @@ namespace PepperDash.Essentials.Core.CrestronIO } catch (Exception e) { - Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key); - Debug.Console(1, this, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); } } @@ -136,7 +137,7 @@ namespace PepperDash.Essentials.Core.CrestronIO { if (!Global.ControlSystem.SupportsVersiport) { - Debug.Console(0, "GetVersiportDigitalOuptut: Processor does not support Versiports"); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Processor does not support Versiports"); return null; } ioPortDevice = Global.ControlSystem; @@ -146,20 +147,20 @@ namespace PepperDash.Essentials.Core.CrestronIO var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts; if (ioPortDev == null) { - Debug.Console(0, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey); return null; } ioPortDevice = ioPortDev; } if (ioPortDevice == null) { - Debug.Console(0, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey); return null; } if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts) { - Debug.Console(0, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); + Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); } var port = ioPortDevice.VersiPorts[dc.PortNumber]; return port; @@ -177,7 +178,7 @@ namespace PepperDash.Essentials.Core.CrestronIO public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs b/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs index 04e697c9..a1cc1e2f 100644 --- a/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs +++ b/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs @@ -4,6 +4,7 @@ using System.Linq; using PepperDash.Core; using Crestron.SimplSharp; using PepperDash.Essentials.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.DeviceInfo { @@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo } ArpTable.Clear(); - Debug.Console(2, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse); + Debug.LogMessage(LogEventLevel.Verbose, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse); var myLines = consoleResponse.Split(NewLineSplitter) @@ -68,7 +69,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo } catch (Exception ex) { - Debug.Console(0, "Exception in \"RefreshArp\" : {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Information, "Exception in \"RefreshArp\" : {0}", ex.Message); error = true; } finally @@ -106,7 +107,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo } catch (Exception ex) { - Debug.Console(0, "Unable to Santize Ip : {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Information, "Unable to Santize Ip : {0}", ex.Message); return ipAddressIn; } } @@ -126,7 +127,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo } catch (Exception ex) { - Debug.Console(0, "Exception Resolving Hostname from IP Address : {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Information, "Exception Resolving Hostname from IP Address : {0}", ex.Message); return ipAddress; } } @@ -145,7 +146,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo } catch (Exception ex) { - Debug.Console(0, "Exception Resolving IP Address from Hostname : {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Information, "Exception Resolving IP Address from Hostname : {0}", ex.Message); return hostName; } } diff --git a/src/PepperDash.Essentials.Core/Devices/CrestronProcessor.cs b/src/PepperDash.Essentials.Core/Devices/CrestronProcessor.cs index 1b0264eb..57d99df8 100644 --- a/src/PepperDash.Essentials.Core/Devices/CrestronProcessor.cs +++ b/src/PepperDash.Essentials.Core/Devices/CrestronProcessor.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core.CrestronIO; +using Serilog.Events; namespace PepperDash.Essentials.Core.Devices { @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Devices } catch (Exception e) { - Debug.Console(1, this, "Error Getting Relays from processor:\n '{0}'", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error Getting Relays from processor:\n '{0}'", e); } } } diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs b/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs index d4c3313d..691aea55 100644 --- a/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs +++ b/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs @@ -10,6 +10,7 @@ using Crestron.SimplSharp.Reflection; using Newtonsoft.Json; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(1, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath); + Debug.LogMessage(LogEventLevel.Debug, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath); return null; } } @@ -198,7 +199,7 @@ namespace PepperDash.Essentials.Core var dev = DeviceManager.GetDeviceForKey(path[0]); if (dev == null) { - Debug.Console(0, "Device {0} not found", path[0]); + Debug.LogMessage(LogEventLevel.Information, "Device {0} not found", path[0]); return null; } @@ -216,20 +217,20 @@ namespace PepperDash.Essentials.Core var indexClose = objName.IndexOf(']'); if (indexClose == -1) { - Debug.Console(0, dev, "ERROR Unmatched index brackets"); + Debug.LogMessage(LogEventLevel.Information, dev, "ERROR Unmatched index brackets"); return null; } // Get the index and strip quotes if any indexStr = objName.Substring(indexOpen + 1, indexClose - indexOpen - 1).Replace("\"", ""); objName = objName.Substring(0, indexOpen); - Debug.Console(0, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr); + Debug.LogMessage(LogEventLevel.Information, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr); } CType oType = obj.GetType(); var prop = oType.GetProperty(objName); if (prop == null) { - Debug.Console(0, dev, "Property {0} not found on {1}", objName, path[i - 1]); + Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} not found on {1}", objName, path[i - 1]); return null; } // if there's an index, try to get the property @@ -237,7 +238,7 @@ namespace PepperDash.Essentials.Core { if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType)) { - Debug.Console(0, dev, "Property {0} is not collection", objName); + Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} is not collection", objName); return null; } var collection = prop.GetValue(obj, null) as ICollection; @@ -247,7 +248,7 @@ namespace PepperDash.Essentials.Core var indexParams = indexedPropInfo.GetIndexParameters(); if (indexParams.Length > 0) { - Debug.Console(0, " Indexed, param type: {0}", indexParams[0].ParameterType.Name); + Debug.LogMessage(LogEventLevel.Information, " Indexed, param type: {0}", indexParams[0].ParameterType.Name); var properParam = Convert.ChangeType(indexStr, indexParams[0].ParameterType, System.Globalization.CultureInfo.InvariantCulture); try @@ -258,9 +259,9 @@ namespace PepperDash.Essentials.Core catch (Crestron.SimplSharp.Reflection.TargetInvocationException e) { if (e.InnerException is ArgumentOutOfRangeException) - Debug.Console(0, " Index Out of range"); + Debug.LogMessage(LogEventLevel.Information, " Index Out of range"); else if (e.InnerException is KeyNotFoundException) - Debug.Console(0, " Key not found"); + Debug.LogMessage(LogEventLevel.Information, " Key not found"); return null; } } diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs index f0101c6c..916cc42f 100644 --- a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs +++ b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core DeviceCriticalSection.Enter(); AddDeviceEnabled = false; // PreActivate all devices - Debug.Console(0,"****PreActivation starting...****"); + Debug.LogMessage(LogEventLevel.Information,"****PreActivation starting...****"); foreach (var d in Devices.Values) { try @@ -73,12 +74,12 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key); + Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); } } - Debug.Console(0, "****PreActivation complete****"); - Debug.Console(0, "****Activation starting...****"); + Debug.LogMessage(LogEventLevel.Information, "****PreActivation complete****"); + Debug.LogMessage(LogEventLevel.Information, "****Activation starting...****"); // Activate all devices foreach (var d in Devices.Values) @@ -90,13 +91,13 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key); + Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); } } - Debug.Console(0, "****Activation complete****"); - Debug.Console(0, "****PostActivation starting...****"); + Debug.LogMessage(LogEventLevel.Information, "****Activation complete****"); + Debug.LogMessage(LogEventLevel.Information, "****PostActivation starting...****"); // PostActivate all devices foreach (var d in Devices.Values) @@ -108,12 +109,12 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key); - Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace); + Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key); + Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); } } - Debug.Console(0, "****PostActivation complete****"); + Debug.LogMessage(LogEventLevel.Information, "****PostActivation complete****"); OnAllDevicesActivated(); } @@ -183,14 +184,14 @@ namespace PepperDash.Essentials.Core private static void ListDevices(string s) { - Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count); + Debug.LogMessage(LogEventLevel.Information, "{0} Devices registered with Device Manager:", Devices.Count); var sorted = Devices.Values.ToList(); sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); foreach (var d in sorted) { var name = d is IKeyName ? (d as IKeyName).Name : "---"; - Debug.Console(0, " [{0}] {1}", d.Key, name); + Debug.LogMessage(LogEventLevel.Information, " [{0}] {1}", d.Key, name); } } @@ -199,13 +200,13 @@ namespace PepperDash.Essentials.Core var dev = GetDeviceForKey(devKey); if (dev == null) { - Debug.Console(0, "Device '{0}' not found", devKey); + Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey); return; } var statusDev = dev as IHasFeedback; if (statusDev == null) { - Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey); + Debug.LogMessage(LogEventLevel.Information, "Device '{0}' does not have visible feedbacks", devKey); return; } statusDev.DumpFeedbacksToConsole(true); @@ -216,10 +217,10 @@ namespace PepperDash.Essentials.Core // var dev = GetDeviceForKey(devKey); // if (dev == null) // { - // Debug.Console(0, "Device '{0}' not found", devKey); + // Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey); // return; // } - // Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey); + // Debug.LogMessage(LogEventLevel.Information, "This needs to be reworked. Stay tuned.", devKey); //} private static void ListDeviceCommStatuses(string input) @@ -236,7 +237,7 @@ namespace PepperDash.Essentials.Core //static void DoDeviceCommand(string command) //{ - // Debug.Console(0, "Not yet implemented. Stay tuned"); + // Debug.LogMessage(LogEventLevel.Information, "Not yet implemented. Stay tuned"); //} public static void AddDevice(IKeyed newDev) @@ -245,7 +246,7 @@ namespace PepperDash.Essentials.Core { if (!DeviceCriticalSection.TryEnter()) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again"); + Debug.LogMessage(LogEventLevel.Information, "Currently unable to add devices to Device Manager. Please try again"); return; } // Check for device with same key @@ -255,13 +256,13 @@ namespace PepperDash.Essentials.Core if (!AddDeviceEnabled) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed."); + Debug.LogMessage(LogEventLevel.Information, "All devices have been activated. Adding new devices is not allowed."); return; } if (Devices.ContainsKey(newDev.Key)) { - Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager"); + Debug.LogMessage(LogEventLevel.Information, newDev, "WARNING: A device with this key already exists. Not added to manager"); return; } Devices.Add(newDev.Key, newDev); @@ -280,13 +281,13 @@ namespace PepperDash.Essentials.Core { if (!DeviceCriticalSection.TryEnter()) { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "Currently unable to add devices to Device Manager. Please try again"); return; } if (!AddDeviceEnabled) { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "All devices have been activated. Adding new devices is not allowed."); return; } @@ -299,7 +300,7 @@ namespace PepperDash.Essentials.Core } catch (ArgumentException ex) { - Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", + Debug.LogMessage(LogEventLevel.Information, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", dev.Key, ex.Message, ex.StackTrace); } } @@ -322,7 +323,7 @@ namespace PepperDash.Essentials.Core //if (_Devices.Contains(newDev)) // _Devices.Remove(newDev); else - Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key); + Debug.LogMessage(LogEventLevel.Information, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key); } finally { @@ -364,7 +365,7 @@ namespace PepperDash.Essentials.Core CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P "); return; } - //Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); + //Debug.LogMessage(LogEventLevel.Verbose, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController; if (com == null) diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs index cd9e3923..e383627d 100644 --- a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -43,8 +44,8 @@ namespace PepperDash.Essentials.Core } catch (Exception ex) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception initializing device: {0}", ex.Message); - Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Error, this, "Exception initializing device: {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Debug, this, "Stack Trace: {0}", ex.StackTrace); } }); } @@ -71,7 +72,7 @@ namespace PepperDash.Essentials.Core public DescriptionAttribute(string description) { - //Debug.Console(2, "Setting Description: {0}", description); + //Debug.LogMessage(LogEventLevel.Verbose, "Setting Description: {0}", description); _Description = description; } @@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Core public ConfigSnippetAttribute(string configSnippet) { - //Debug.Console(2, "Setting Config Snippet {0}", configSnippet); + //Debug.LogMessage(LogEventLevel.Verbose, "Setting Config Snippet {0}", configSnippet); _ConfigSnippet = configSnippet; } @@ -117,7 +118,7 @@ namespace PepperDash.Essentials.Core { foreach (var typeName in TypeNames) { - //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); + //Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; string description = descriptionAttribute[0].Description; var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; @@ -151,7 +152,7 @@ namespace PepperDash.Essentials.Core { foreach (var typeName in TypeNames) { - //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); + //Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; string description = descriptionAttribute[0].Description; var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; diff --git a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs index d0c6a61b..26718ebf 100644 --- a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs +++ b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs @@ -9,6 +9,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges.JoinMaps; +using Serilog.Events; namespace PepperDash.Essentials.Core.Devices { @@ -29,7 +30,7 @@ namespace PepperDash.Essentials.Core.Devices _port = irPort; if (_port == null) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function"); + Debug.LogMessage(LogEventLevel.Information, this, "IR Port is null, device will not function"); return; } DeviceManager.AddDevice(_port); @@ -75,12 +76,12 @@ namespace PepperDash.Essentials.Core.Devices if (_port.UseBridgeJoinMap) { - Debug.Console(0, this, "Using new IR bridge join map"); + Debug.LogMessage(LogEventLevel.Information, this, "Using new IR bridge join map"); var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key); if (bridgeJoins == null) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map"); + Debug.LogMessage(LogEventLevel.Information, this, "Failed to link new IR bridge join map"); return; } @@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Core.Devices var joinDataValue = bridgeJoin.Value.Value; var joinNumber = bridgeJoin.Value.Value.JoinNumber; - Debug.Console(2, this, @"bridgeJoin: Key-'{0}' + Debug.LogMessage(LogEventLevel.Verbose, this, @"bridgeJoin: Key-'{0}' Value.Key-'{1}' Value.JoinNumber-'{2}' Value.Metadata.Description-'{3}'", @@ -110,7 +111,7 @@ Value.Metadata.Description-'{3}'", } else { - Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands"); + Debug.LogMessage(LogEventLevel.Information, this, "Using legacy IR join mapping based on available IR commands"); joinMap.Joins.Clear(); @@ -141,7 +142,7 @@ Value.Metadata.Description-'{3}'", } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } } @@ -163,7 +164,7 @@ Value.Metadata.Description-'{3}'", public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic IR Controller Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic IR Controller Device"); var irPort = IRPortHelper.GetIrOutputPortController(dc); diff --git a/src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs b/src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs index 1bf8edb9..8929edeb 100644 --- a/src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs +++ b/src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Devices @@ -25,7 +26,7 @@ namespace PepperDash.Essentials.Core.Devices // ------------------------------------------------------DELETE THIS CommunicationMonitor.StatusChange += (o, a) => { - Debug.Console(2, this, "Communication monitor status change: {0}", a.Status); + Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor status change: {0}", a.Status); }; } diff --git a/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs b/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs index cc5e1054..5241a147 100644 --- a/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs +++ b/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs @@ -4,6 +4,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharp.Reflection; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -29,7 +30,7 @@ namespace PepperDash.Essentials.Core var feedbacks = source.Feedbacks; if (feedbacks != null) { - Debug.Console(0, source, "\n\nAvailable feedbacks:"); + Debug.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:"); foreach (var f in feedbacks) { string val = ""; @@ -52,12 +53,12 @@ namespace PepperDash.Essentials.Core type = "string"; } } - Debug.Console(0, "{0,-12} {1, -25} {2}", type, + Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type, (string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val); } } else - Debug.Console(0, source, "No available outputs:"); + Debug.LogMessage(LogEventLevel.Information, source, "No available outputs:"); } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs b/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs index 05b59366..968fa127 100644 --- a/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs +++ b/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -84,14 +85,14 @@ namespace PepperDash.Essentials.Core if (handler != null) { - Debug.Console(1, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); + Debug.LogMessage(LogEventLevel.Debug, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); } } } catch (Exception e) { - Debug.Console(1, "Error ending device usage: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, "Error ending device usage: {0}", e); } } } diff --git a/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs b/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs index d65d1f7b..45c2d895 100644 --- a/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs +++ b/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs @@ -11,6 +11,7 @@ using PepperDash.Essentials.Core.Config; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -46,7 +47,7 @@ namespace PepperDash.Essentials.Core IrPort = port; if (port == null) { - Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function"); return; } LoadDriver(irDriverFilepath); @@ -64,12 +65,12 @@ namespace PepperDash.Essentials.Core if (IrPort == null) { - Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function"); return; } var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); - Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); + Debug.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath); LoadDriver(filePath); @@ -79,10 +80,10 @@ namespace PepperDash.Essentials.Core public void PrintAvailableCommands() { - Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid); + Debug.LogMessage(LogEventLevel.Verbose, this, "Available IR Commands in IR File {0}", IrPortUid); foreach (var cmd in IrPort.AvailableIRCmds()) { - Debug.Console(2, this, "{0}", cmd); + Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", cmd); } } @@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Core /// public void LoadDriver(string path) { - Debug.Console(2, this, "***Loading IR File***"); + Debug.LogMessage(LogEventLevel.Verbose, this, "***Loading IR File***"); if (string.IsNullOrEmpty(path)) path = DriverFilepath; try { @@ -108,7 +109,7 @@ namespace PepperDash.Essentials.Core { DriverIsLoaded = false; var message = string.Format("WARNING IR Driver '{0}' failed to load", path); - Debug.Console(0, this, Debug.ErrorLogLevel.Error, message); + Debug.LogMessage(LogEventLevel.Information, this, message); DriverLoaded.FireUpdate(); } } @@ -119,15 +120,15 @@ namespace PepperDash.Essentials.Core /// public virtual void PressRelease(string command, bool state) { - Debug.Console(2, this, "IR:'{0}'={1}", command, state); + Debug.LogMessage(LogEventLevel.Verbose, this, "IR:'{0}'={1}", command, state); if (IrPort == null) { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller"); return; } if (!DriverIsLoaded) { - Debug.Console(2, this, "WARNING IR driver is not loaded"); + Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded"); return; } if (state) @@ -148,12 +149,12 @@ namespace PepperDash.Essentials.Core { if (IrPort == null) { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller"); return; } if (!DriverIsLoaded) { - Debug.Console(2, this, "WARNING IR driver is not loaded"); + Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded"); return; } if (IrPort.IsIRCommandAvailable(IrPortUid, command)) @@ -167,7 +168,7 @@ namespace PepperDash.Essentials.Core /// protected void NoIrCommandError(string command) { - Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}", + Debug.LogMessage(LogEventLevel.Verbose, this, "Device {0}: IR Driver {1} does not contain command {2}", Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); } } diff --git a/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs index 12b3f0c8..0b9e5815 100644 --- a/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs +++ b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs @@ -7,6 +7,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Devices { @@ -73,7 +74,7 @@ namespace PepperDash.Essentials.Core.Devices public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new InRoomPc Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new InRoomPc Device"); return new InRoomPc(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs b/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs index 28069c76..bfc09292 100644 --- a/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs +++ b/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs @@ -7,6 +7,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Devices { @@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core.Devices public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Laptop Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Laptop Device"); return new Core.Devices.Laptop(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs b/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs index 121a1874..a921f07b 100644 --- a/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs +++ b/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs @@ -11,6 +11,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -43,8 +44,8 @@ namespace PepperDash.Essentials.Core IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath); DeviceManager.AddDevice(IrPort); - IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp); - IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown); + IsWarmingUpFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Warming up={0}", _IsWarmingUp); + IsCoolingDownFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Cooling down={0}", _IsCoolingDown); InputPorts.AddRange(new RoutingPortCollection { @@ -170,7 +171,7 @@ namespace PepperDash.Essentials.Core /// A delegate containing the input selector method to call public override void ExecuteSwitch(object inputSelector) { - Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); Action finishSwitch = () => { @@ -213,7 +214,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BasicIrDisplay Device"); var ir = IRPortHelper.GetIrPort(dc.Properties); if (ir != null) { diff --git a/src/PepperDash.Essentials.Core/Display/DisplayBase.cs b/src/PepperDash.Essentials.Core/Display/DisplayBase.cs index 9ba42cab..edfe8f1d 100644 --- a/src/PepperDash.Essentials.Core/Display/DisplayBase.cs +++ b/src/PepperDash.Essentials.Core/Display/DisplayBase.cs @@ -11,6 +11,7 @@ using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -113,7 +114,7 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } LinkDisplayToApi(displayDevice, trilist, joinMap); @@ -121,8 +122,8 @@ namespace PepperDash.Essentials.Core protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap) { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, "Linking to Display: {0}", displayDevice.Name); trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; @@ -144,7 +145,7 @@ namespace PepperDash.Essentials.Core { trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); - twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); + twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Information, "CurrentInputFeedback_OutputChange {0}", a.StringValue); inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); @@ -198,16 +199,16 @@ namespace PepperDash.Essentials.Core var tempKey = inputKeys.ElementAt(i); trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", + Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString()); trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); } else - Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", + Debug.LogMessage(LogEventLevel.Information, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); } - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => { if (a == 0) diff --git a/src/PepperDash.Essentials.Core/Display/MockDisplay.cs b/src/PepperDash.Essentials.Core/Display/MockDisplay.cs index db568519..7c9f0446 100644 --- a/src/PepperDash.Essentials.Core/Display/MockDisplay.cs +++ b/src/PepperDash.Essentials.Core/Display/MockDisplay.cs @@ -13,6 +13,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -36,7 +37,7 @@ namespace PepperDash.Essentials.Core { return () => { - Debug.Console(2, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); return _PowerIsOn; }; } } @@ -46,7 +47,7 @@ namespace PepperDash.Essentials.Core { return () => { - Debug.Console(2, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); return _IsCoolingDown; }; } @@ -57,7 +58,7 @@ namespace PepperDash.Essentials.Core { return () => { - Debug.Console(2, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); return _IsWarmingUp; }; } @@ -119,7 +120,7 @@ namespace PepperDash.Essentials.Core // Fake cool-down cycle CooldownTimer = new CTimer(o => { - Debug.Console(2, this, "Cooldown timer ending"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Cooldown timer ending"); _IsCoolingDown = false; IsCoolingDownFeedback.InvokeFireUpdate(); _PowerIsOn = false; @@ -138,7 +139,7 @@ namespace PepperDash.Essentials.Core public override void ExecuteSwitch(object selector) { - Debug.Console(2, this, "ExecuteSwitch: {0}", selector); + Debug.LogMessage(LogEventLevel.Verbose, this, "ExecuteSwitch: {0}", selector); if (!_PowerIsOn) { @@ -180,7 +181,7 @@ namespace PepperDash.Essentials.Core { //while (pressRelease) //{ - Debug.Console(2, this, "Volume Down {0}", pressRelease); + Debug.LogMessage(LogEventLevel.Verbose, this, "Volume Down {0}", pressRelease); if (pressRelease) { var newLevel = _FakeVolumeLevel + VolumeInterval; @@ -194,7 +195,7 @@ namespace PepperDash.Essentials.Core { //while (pressRelease) //{ - Debug.Console(2, this, "Volume Up {0}", pressRelease); + Debug.LogMessage(LogEventLevel.Verbose, this, "Volume Up {0}", pressRelease); if (pressRelease) { var newLevel = _FakeVolumeLevel - VolumeInterval; @@ -229,7 +230,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Mock Display Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Mock Display Device"); return new MockDisplay(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs index db6c07cc..65b410e6 100644 --- a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs @@ -5,6 +5,7 @@ using Crestron.SimplSharp.Reflection; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; @@ -44,7 +45,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + Debug.LogMessage(LogEventLevel.Information, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); } } } @@ -64,17 +65,17 @@ namespace PepperDash.Essentials.Core /// public static void AddFactoryForType(string typeName, Func method) { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method}); } public static void AddFactoryForType(string typeName, string description, CType cType, Func method) { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); if(FactoryMethods.ContainsKey(typeName)) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName); + Debug.LogMessage(LogEventLevel.Information, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName); return; } @@ -104,7 +105,7 @@ namespace PepperDash.Essentials.Core if (secretProvider == null) return null; var secret = secretProvider.GetSecret(data.Key); if (secret != null) return (string) secret.Value; - Debug.Console(1, + Debug.LogMessage(LogEventLevel.Debug, "Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider", data.Provider, data.Key); return String.Empty; @@ -121,7 +122,7 @@ namespace PepperDash.Essentials.Core { try { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type); + Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type); var localDc = new DeviceConfig(dc); @@ -142,24 +143,24 @@ namespace PepperDash.Essentials.Core CheckForSecrets(jProp); } - Debug.Console(2, "typeName = {0}", typeName); + Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName); // Check for types that have been added by plugin dlls. return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc); } catch (Exception ex) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); + Debug.LogMessage(LogEventLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); - Debug.Console(2, "{0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.StackTrace); if (ex.InnerException == null) { return null; } - Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, + Debug.LogMessage(LogEventLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, ex.InnerException.Message); - Debug.Console(2, "{0}", ex.InnerException.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.InnerException.StackTrace); return null; } } diff --git a/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs index 4f78892a..68f5dc1f 100644 --- a/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs @@ -1,9 +1,8 @@  using Crestron.SimplSharp.Reflection; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; @@ -31,7 +30,7 @@ namespace PepperDash.Essentials.Core } catch( Exception e ) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name); + Debug.LogMessage(LogEventLevel.Information, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name); } } } @@ -52,17 +51,17 @@ namespace PepperDash.Essentials.Core /// public static void AddFactoryForType(string extensionName, Func method) { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method }); } public static void AddFactoryForType(string extensionName, string description, CType cType, Func method) { - //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + //Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); if (ProcessorExtensionFactoryMethods.ContainsKey(extensionName)) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName); + Debug.LogMessage(LogEventLevel.Information, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName); return; } @@ -92,7 +91,7 @@ namespace PepperDash.Essentials.Core if (secretProvider == null) return null; var secret = secretProvider.GetSecret(data.Key); if (secret != null) return (string)secret.Value; - Debug.Console(1, + Debug.LogMessage(LogEventLevel.Debug, "Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider", data.Provider, data.Key); return String.Empty; @@ -108,7 +107,7 @@ namespace PepperDash.Essentials.Core { try { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type); + Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type); var localDc = new DeviceConfig(dc); @@ -128,24 +127,24 @@ namespace PepperDash.Essentials.Core CheckForSecrets(jProp); } - Debug.Console(2, "typeName = {0}", typeName); + Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName); // Check for types that have been added by plugin dlls. return !ProcessorExtensionFactoryMethods.ContainsKey(typeName) ? null : ProcessorExtensionFactoryMethods[typeName].FactoryMethod(localDc); } catch (Exception ex) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); + Debug.LogMessage(LogEventLevel.Information, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); - Debug.Console(2, "{0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.StackTrace); if (ex.InnerException == null) { return null; } - Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, + Debug.LogMessage(LogEventLevel.Information, "Inner exception while creating device {0}: {1}", dc.Key, ex.InnerException.Message); - Debug.Console(2, "{0}", ex.InnerException.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.InnerException.StackTrace); return null; } } diff --git a/src/PepperDash.Essentials.Core/File/FileIO.cs b/src/PepperDash.Essentials.Core/File/FileIO.cs index 49b70a0c..6398e8c6 100644 --- a/src/PepperDash.Essentials.Core/File/FileIO.cs +++ b/src/PepperDash.Essentials.Core/File/FileIO.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; using PepperDash.Core; using Crestron.SimplSharpPro.CrestronThread; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -26,7 +27,7 @@ namespace PepperDash.Essentials.Core string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + Debug.LogMessage(LogEventLevel.Information, "FileIO found: {0}, {1}", files.Count(), fullFilePath); if (files.Count() > 0) { return files; @@ -42,7 +43,7 @@ namespace PepperDash.Essentials.Core string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + Debug.LogMessage(LogEventLevel.Information, "FileIO found: {0}, {1}", files.Count(), fullFilePath); if (files.Count() > 0) { return files.FirstOrDefault(); @@ -67,7 +68,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); return ""; } } @@ -84,7 +85,7 @@ namespace PepperDash.Essentials.Core if (fileLock.TryEnter()) { DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName); - Debug.Console(2, "FileIO Getting Data {0}", file.FullName); + Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName); if (File.Exists(file.FullName)) { @@ -95,20 +96,20 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(2, "File {0} does not exsist", file.FullName); + Debug.LogMessage(LogEventLevel.Verbose, "File {0} does not exsist", file.FullName); return ""; } } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock"); + Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); return ""; } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); return ""; } finally @@ -128,7 +129,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); } } @@ -140,7 +141,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); } } @@ -152,7 +153,7 @@ namespace PepperDash.Essentials.Core if (fileLock.TryEnter()) { DirectoryInfo dirInfo = new DirectoryInfo(file.Name); - Debug.Console(2, "FileIO Getting Data {0}", file.FullName); + Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName); if (File.Exists(file.FullName)) @@ -164,20 +165,20 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(2, "File {0} Does not exsist", file.FullName); + Debug.LogMessage(LogEventLevel.Verbose, "File {0} Does not exsist", file.FullName); data = ""; } GotFileEvent.Invoke(null, new FileEventArgs(data)); } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock"); + Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); data = ""; } finally @@ -207,13 +208,13 @@ namespace PepperDash.Essentials.Core _WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended); _WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority; _WriteFileThread.Start(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread"); + Debug.LogMessage(LogEventLevel.Information, "New WriteFile Thread"); } static object _WriteFileMethod(string data, string filePath) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write file: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Attempting to write file: '{0}'", filePath); try { @@ -229,13 +230,13 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock"); + Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); } } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO write failed: \r{0}", e); + Debug.LogMessage(LogEventLevel.Error, "Error: FileIO write failed: \r{0}", e); } finally { @@ -259,7 +260,7 @@ namespace PepperDash.Essentials.Core var file = FileIO.GetFile("\\user\\*FileIOTest*"); var readData = FileIO.ReadDataFromFile(file); - Debug.Console(0, "Returned {0}", readData); + Debug.LogMessage(LogEventLevel.Information, "Returned {0}", readData); File.Delete(file.FullName); if (testData == readData) { diff --git a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index b15fe095..050d6cd8 100644 --- a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -13,6 +13,7 @@ using Crestron.SimplSharpPro.Fusion; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core.Fusion { @@ -128,7 +129,7 @@ namespace PepperDash.Essentials.Core.Fusion if (File.Exists(oldGuidFilePath)) { - Debug.Console(0, this, "Migrating from old Fusion GUID file to new Fusion GUID File"); + Debug.LogMessage(LogEventLevel.Information, this, "Migrating from old Fusion GUID file to new Fusion GUID File"); File.Copy(oldGuidFilePath, guidFilePath); @@ -172,7 +173,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Error Building Fusion System Controller: {0}", e); + Debug.LogMessage(LogEventLevel.Information, this, "Error Building Fusion System Controller: {0}", e); } } @@ -231,7 +232,7 @@ namespace PepperDash.Essentials.Core.Fusion { if (string.IsNullOrEmpty(filePath)) { - Debug.Console(0, this, "Error writing guid file. No path specified."); + Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file. No path specified."); return; } @@ -246,7 +247,7 @@ namespace PepperDash.Essentials.Core.Fusion fileLock.Enter(); - Debug.Console(1, this, "Writing GUIDs to file"); + Debug.LogMessage(LogEventLevel.Debug, this, "Writing GUIDs to file"); _guiDs = FusionOccSensor == null ? new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets) @@ -260,11 +261,11 @@ namespace PepperDash.Essentials.Core.Fusion sw.Flush(); } - Debug.Console(1, this, "Guids successfully written to file '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Debug, this, "Guids successfully written to file '{0}'", filePath); } catch (Exception e) { - Debug.Console(0, this, "Error writing guid file: {0}", e); + Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file: {0}", e); } finally { @@ -283,7 +284,7 @@ namespace PepperDash.Essentials.Core.Fusion { if (string.IsNullOrEmpty(filePath)) { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file. No path specified."); + Debug.LogMessage(LogEventLevel.Information, this, "Error reading guid file. No path specified."); return; } @@ -309,20 +310,20 @@ namespace PepperDash.Essentials.Core.Fusion FusionStaticAssets = _guiDs.StaticAssets; } - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Fusion Guids successfully read from file: {0}", + Debug.LogMessage(LogEventLevel.Information, this, "Fusion Guids successfully read from file: {0}", filePath); - Debug.Console(1, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid); + Debug.LogMessage(LogEventLevel.Debug, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid); foreach (var item in FusionStaticAssets) { - Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, + Debug.LogMessage(LogEventLevel.Debug, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, item.Value.SlotNumber, item.Value.InstanceId); } } catch (Exception e) { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file: {0}", e); + Debug.LogMessage(LogEventLevel.Information, this, "Error reading guid file: {0}", e); } finally { @@ -335,7 +336,7 @@ namespace PepperDash.Essentials.Core.Fusion protected virtual void CreateSymbolAndBasicSigs(uint ipId) { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); + Debug.LogMessage(LogEventLevel.Information, this, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); @@ -554,7 +555,7 @@ namespace PepperDash.Essentials.Core.Fusion "\n" + "\n"; - Debug.Console(2, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); + Debug.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest; @@ -605,7 +606,7 @@ namespace PepperDash.Essentials.Core.Fusion "FullSchedleRequest{0}{1}24", RoomGuid, currentTime); - Debug.Console(2, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest); + Debug.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest); FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest; @@ -633,7 +634,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, this, "Error parsing console command: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing console command: {0}", e); } ModifyMeetingEndTime(requestId, extendMinutes); @@ -648,7 +649,7 @@ namespace PepperDash.Essentials.Core.Fusion { if (_currentMeeting == null) { - Debug.Console(1, this, "No meeting in progress. Unable to modify end time."); + Debug.LogMessage(LogEventLevel.Debug, this, "No meeting in progress. Unable to modify end time."); return; } @@ -667,13 +668,13 @@ namespace PepperDash.Essentials.Core.Fusion "{0}{1}MeetingChange" , requestId, RoomGuid, _currentMeeting.MeetingID, extendMinutes); - Debug.Console(1, this, "Sending MeetingChange Request: \n{0}", requestTest); + Debug.LogMessage(LogEventLevel.Debug, this, "Sending MeetingChange Request: \n{0}", requestTest); FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest; } else { - Debug.Console(1, this, "Invalid time specified"); + Debug.LogMessage(LogEventLevel.Debug, this, "Invalid time specified"); } } @@ -716,11 +717,11 @@ namespace PepperDash.Essentials.Core.Fusion "" + ""; - Debug.Console(2, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest); + Debug.LogMessage(LogEventLevel.Verbose, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest); FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest; - //Debug.Console(1, this, "Sending CreateMeeting Request: \n{0}", command); + //Debug.LogMessage(LogEventLevel.Debug, this, "Sending CreateMeeting Request: \n{0}", command); //FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command; } @@ -733,7 +734,7 @@ namespace PepperDash.Essentials.Core.Fusion protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) { - Debug.Console(2, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, + Debug.LogMessage(LogEventLevel.Verbose, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, args.Sig.StringValue); @@ -802,7 +803,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, this, "Error parsing ActionQueryResponse: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ActionQueryResponse: {0}", e); } } else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse) @@ -825,20 +826,20 @@ namespace PepperDash.Essentials.Core.Fusion var currentTime = DateTime.Parse(tempLocalDateTime); - Debug.Console(1, this, "DateTime from Fusion Server: {0}", currentTime); + Debug.LogMessage(LogEventLevel.Debug, this, "DateTime from Fusion Server: {0}", currentTime); // Parse time and date from response and insert values CrestronEnvironment.SetTimeAndDate((ushort) currentTime.Hour, (ushort) currentTime.Minute, (ushort) currentTime.Second, (ushort) currentTime.Month, (ushort) currentTime.Day, (ushort) currentTime.Year); - Debug.Console(1, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime()); + Debug.LogMessage(LogEventLevel.Debug, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime()); } } } catch (Exception e) { - Debug.Console(1, this, "Error parsing LocalDateTimeQueryResponse: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing LocalDateTimeQueryResponse: {0}", e); } } else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse) @@ -847,7 +848,7 @@ namespace PepperDash.Essentials.Core.Fusion var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and"); - Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs); + Debug.LogMessage(LogEventLevel.Verbose, this, "Fusion Response: \n {0}", roomConfigResponseArgs); try { @@ -912,7 +913,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, this, "Error parsing Custom Properties response: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing Custom Properties response: {0}", e); } //PrintRoomInfo(); //getRoomInfoBusy = false; @@ -928,7 +929,7 @@ namespace PepperDash.Essentials.Core.Fusion protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) { - Debug.Console(2, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, + Debug.LogMessage(LogEventLevel.Verbose, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, args.Sig.StringValue); @@ -980,7 +981,7 @@ namespace PepperDash.Essentials.Core.Fusion } else if (element.Name == "Event") { - Debug.Console(2, this, "Event Found:\n{0}", element.OuterXml); + Debug.LogMessage(LogEventLevel.Verbose, this, "Event Found:\n{0}", element.OuterXml); var reader = new XmlReader(element.OuterXml); @@ -1024,12 +1025,12 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, this, "Error parsing ScheduleResponse: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ScheduleResponse: {0}", e); } } else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) { - Debug.Console(2, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, + Debug.LogMessage(LogEventLevel.Verbose, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, args.Sig.StringValue); } } @@ -1043,16 +1044,16 @@ namespace PepperDash.Essentials.Core.Fusion { if (_currentSchedule.Meetings.Count > 0) { - Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Today's Schedule for '{0}'\n", Room.Name); foreach (var e in _currentSchedule.Meetings) { - Debug.Console(1, this, "Subject: {0}", e.Subject); - Debug.Console(1, this, "Organizer: {0}", e.Organizer); - Debug.Console(1, this, "MeetingID: {0}", e.MeetingID); - Debug.Console(1, this, "Start Time: {0}", e.dtStart); - Debug.Console(1, this, "End Time: {0}", e.dtEnd); - Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes); + Debug.LogMessage(LogEventLevel.Debug, this, "Subject: {0}", e.Subject); + Debug.LogMessage(LogEventLevel.Debug, this, "Organizer: {0}", e.Organizer); + Debug.LogMessage(LogEventLevel.Debug, this, "MeetingID: {0}", e.MeetingID); + Debug.LogMessage(LogEventLevel.Debug, this, "Start Time: {0}", e.dtStart); + Debug.LogMessage(LogEventLevel.Debug, this, "End Time: {0}", e.dtEnd); + Debug.LogMessage(LogEventLevel.Debug, this, "Duration: {0}\n", e.DurationInMinutes); } } } @@ -1110,7 +1111,7 @@ namespace PepperDash.Essentials.Core.Fusion } else { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", + Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Config source list '{0}' not found for room '{1}'", Room.SourceListKey, Room.Key); } } @@ -1144,18 +1145,18 @@ namespace PepperDash.Essentials.Core.Fusion e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH:mm:ss"), @group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId); - Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", + Debug.LogMessage(LogEventLevel.Debug, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed); FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; - Debug.Console(1, this, "Device usage string: {0}", deviceUsage); + Debug.LogMessage(LogEventLevel.Debug, this, "Device usage string: {0}", deviceUsage); } protected void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc) { - Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}", + Debug.LogMessage(LogEventLevel.Verbose, this, "Creating attribute '{0}' with join {1} for source {2}", attrName, attrNum, pSrc.Key); try { @@ -1176,7 +1177,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception) { - Debug.Console(2, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING", + Debug.LogMessage(LogEventLevel.Verbose, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING", attrNum, attrName, pSrc.Key); } } @@ -1205,7 +1206,7 @@ namespace PepperDash.Essentials.Core.Fusion //var keyNum = ExtractNumberFromKey(dev.Key); //if (keyNum == -1) //{ - // Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", + // Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", // dev.Key); // continue; //} @@ -1277,7 +1278,7 @@ namespace PepperDash.Essentials.Core.Fusion sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk; smd.CommunicationMonitor.StatusChange += (o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; }; - Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName); + Debug.LogMessage(LogEventLevel.Information, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName); } } } @@ -1306,7 +1307,7 @@ namespace PepperDash.Essentials.Core.Fusion var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase; if (defaultDisplay == null) { - Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); + Debug.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null"); return; } @@ -1374,7 +1375,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Error setting up display in Fusion: {0}", e); } } @@ -1467,7 +1468,7 @@ namespace PepperDash.Essentials.Core.Fusion if (md != null) { _errorMessageRollUp.AddMonitor(md.CommunicationMonitor); - Debug.Console(2, this, "Adding '{0}' to room's overall error monitor", + Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor", md.CommunicationMonitor.Parent.Key); } } @@ -1704,19 +1705,19 @@ namespace PepperDash.Essentials.Core.Fusion { try { - Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); + Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; } catch (InvalidOperationException ex) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); + Debug.LogMessage(LogEventLevel.Information, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); return null; } catch (Exception e) { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, "Error creating Static Asset: {0}", e); return null; } } @@ -1726,7 +1727,7 @@ namespace PepperDash.Essentials.Core.Fusion { try { - Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, + Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); @@ -1734,12 +1735,12 @@ namespace PepperDash.Essentials.Core.Fusion } catch (InvalidOperationException ex) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + Debug.LogMessage(LogEventLevel.Information, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); return null; } catch (Exception e) { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + Debug.LogMessage(LogEventLevel.Error, "Error creating Static Asset: {0}", e); return null; } } diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionCustomPropertiesBridge.cs b/src/PepperDash.Essentials.Core/Fusion/FusionCustomPropertiesBridge.cs index 86eeffc3..a0cd8e6e 100644 --- a/src/PepperDash.Essentials.Core/Fusion/FusionCustomPropertiesBridge.cs +++ b/src/PepperDash.Essentials.Core/Fusion/FusionCustomPropertiesBridge.cs @@ -12,6 +12,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; +using Serilog.Events; namespace PepperDash.Essentials.Core.Fusion { @@ -38,7 +39,7 @@ namespace PepperDash.Essentials.Core.Fusion if (device is RoomOnToDefaultSourceWhenOccupied) { - Debug.Console(1, "Mapping Room on via Occupancy values from Fusion"); + Debug.LogMessage(LogEventLevel.Debug, "Mapping Room on via Occupancy values from Fusion"); var devProps = JsonConvert.DeserializeObject(deviceConfig.Properties.ToString()); @@ -89,18 +90,18 @@ namespace PepperDash.Essentials.Core.Fusion // Set the room name if (!string.IsNullOrEmpty(roomInfo.Name)) { - Debug.Console(1, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name); + Debug.LogMessage(LogEventLevel.Debug, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name); // Set the name in config deviceConfig.Name = roomInfo.Name; - Debug.Console(1, "Room Name Successfully Changed."); + Debug.LogMessage(LogEventLevel.Debug, "Room Name Successfully Changed."); } // Set the help message var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage")); if (helpMessage != null) { - //Debug.Console(1, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value(ToString()), helpMessage.CustomFieldValue); + //Debug.LogMessage(LogEventLevel.Debug, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value(ToString()), helpMessage.CustomFieldValue); deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue; } } @@ -113,7 +114,7 @@ namespace PepperDash.Essentials.Core.Fusion } catch (Exception e) { - Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e); + Debug.LogMessage(LogEventLevel.Debug, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e); } } } diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs b/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs index 62109d97..cdf1dfa8 100644 --- a/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs +++ b/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Fusion { @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Fusion } } programs[i] = item; - Debug.Console(1, "Program {0}: {1}", i, item.Name); + Debug.LogMessage(LogEventLevel.Debug, "Program {0}: {1}", i, item.Name); } return programs; } diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs b/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs index 99fc0abb..1ac5dbde 100644 --- a/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs +++ b/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro.Fusion; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Fusion { @@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core.Fusion { var slotNum = GetNextAvailableAssetNumber(room); - Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); + Debug.LogMessage(LogEventLevel.Verbose, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId); @@ -105,7 +106,7 @@ namespace PepperDash.Essentials.Core.Fusion else slotNum = slotNum + 1; - Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum); + Debug.LogMessage(LogEventLevel.Verbose, "#Next available fusion asset number is: {0}", slotNum); return slotNum; } diff --git a/src/PepperDash.Essentials.Core/Global/Global.cs b/src/PepperDash.Essentials.Core/Global/Global.cs index 59d37b56..b69143af 100644 --- a/src/PepperDash.Essentials.Core/Global/Global.cs +++ b/src/PepperDash.Essentials.Core/Global/Global.cs @@ -17,6 +17,7 @@ using PepperDash.Essentials.License; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -169,28 +170,28 @@ namespace PepperDash.Essentials.Core { if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0") { - Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); + Debug.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check."); return true; } if (developmentVersions == null) { - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, "Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version"); return IsRunningMinimumVersionOrHigher(minimumVersion); } - Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); + Debug.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion); if (String.IsNullOrEmpty(versionMatch)) { - Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); + Debug.LogMessage(LogEventLevel.Information, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); return false; } - Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion); + Debug.LogMessage(LogEventLevel.Verbose, "Essentials Build {0} matches list of development builds", AssemblyVersion); return IsRunningMinimumVersionOrHigher(minimumVersion); @@ -204,11 +205,11 @@ namespace PepperDash.Essentials.Core /// Returns true if the running version meets or exceeds the minimum specified version public static bool IsRunningMinimumVersionOrHigher(string minimumVersion) { - Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); + Debug.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); if (String.IsNullOrEmpty(minimumVersion)) { - Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); + Debug.LogMessage(LogEventLevel.Information,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); return true; } @@ -227,7 +228,7 @@ namespace PepperDash.Essentials.Core } catch { - Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); + Debug.LogMessage(LogEventLevel.Verbose, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); return false; } @@ -238,7 +239,7 @@ namespace PepperDash.Essentials.Core return runtimeVer.CompareTo(minimumVer) >= 0; } - Debug.Console(2, "Running Local Build. Bypassing Dependency Check."); + Debug.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check."); return true; /* diff --git a/src/PepperDash.Essentials.Core/Global/Scheduler.cs b/src/PepperDash.Essentials.Core/Global/Scheduler.cs index 960a56ef..2efefa36 100644 --- a/src/PepperDash.Essentials.Core/Global/Scheduler.cs +++ b/src/PepperDash.Essentials.Core/Global/Scheduler.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharp.Scheduler; using PepperDash.Core; using PepperDash.Essentials.Core.Fusion; using PepperDash.Essentials.Room.Config; +using Serilog.Events; using Activator = System.Activator; namespace PepperDash.Essentials.Core @@ -38,7 +39,7 @@ namespace PepperDash.Essentials.Core { if (!EventGroups.ContainsKey(groupName)) { - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", groupName); return; @@ -50,38 +51,38 @@ namespace PepperDash.Essentials.Core { group.ClearAllEvents(); - Debug.Console(0, "[Scheduler]: All events deleted from group '{0}'", groupName); + Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: All events deleted from group '{0}'", groupName); } else - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", groupName); } static void ListAllEventGroups(string command) { - Debug.Console(0, "Event Groups:"); + Debug.LogMessage(LogEventLevel.Information, "Event Groups:"); foreach (var group in EventGroups) { - Debug.Console(0, "{0}", group.Key); + Debug.LogMessage(LogEventLevel.Information, "{0}", group.Key); } } static void ListAllEventsForGroup(string args) { - Debug.Console(0, "Getting events for group {0}...", args); + Debug.LogMessage(LogEventLevel.Information, "Getting events for group {0}...", args); ScheduledEventGroup group; if (!EventGroups.TryGetValue(args, out group)) { - Debug.Console(0, "Unabled to get event group for key {0}", args); + Debug.LogMessage(LogEventLevel.Information, "Unabled to get event group for key {0}", args); return; } foreach (var evt in group.ScheduledEvents) { - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, @" ****Event key {0}**** Event date/time: {1} @@ -137,7 +138,7 @@ Recurrence Days: {5} var dayOfWeek = eventTime.DayOfWeek; - Debug.Console(1, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek); + Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek); switch (dayOfWeek) { @@ -185,7 +186,7 @@ Recurrence Days: {5} } } - Debug.Console(1, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch); + Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch); return isMatch; } @@ -204,7 +205,7 @@ Recurrence Days: {5} { if (group == null) { - Debug.Console(0, "Unable to create event. Group is null"); + Debug.LogMessage(LogEventLevel.Information, "Unable to create event. Group is null"); return; } var scheduledEvent = new ScheduledEvent(config.Key, group) @@ -224,12 +225,12 @@ Recurrence Days: {5} eventTime = eventTime.AddDays(1); } - Debug.Console(2, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek, + Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek, config.Days); var dayOfWeekConverted = ConvertDayOfWeek(eventTime); - Debug.Console(1, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted); + Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted); while (!dayOfWeekConverted.IsFlagSet(config.Days)) { diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs index 6138c003..f8a7e4d2 100644 --- a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs @@ -13,6 +13,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core.Config; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -57,11 +58,11 @@ namespace PepperDash.Essentials.Core if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) { - Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey); + Debug.LogMessage(LogEventLevel.Verbose, "No Join Map found in config with key: '{0}'", joinMapKey); return null; } - Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey); + Debug.LogMessage(LogEventLevel.Verbose, "Attempting to load custom join map with key: {0}", joinMapKey); var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; @@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core } catch (Exception e) { - Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); + Debug.LogMessage(LogEventLevel.Verbose, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); return null; } } @@ -120,7 +121,7 @@ namespace PepperDash.Essentials.Core if (value == null) { - Debug.Console(0, "Unable to cast base class to {0}", type.Name); + Debug.LogMessage(LogEventLevel.Information, "Unable to cast base class to {0}", type.Name); continue; } @@ -271,7 +272,7 @@ namespace PepperDash.Essentials.Core if (!Joins.TryGetValue(customJoinData.Key, out join)) { - Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); + Debug.LogMessage(LogEventLevel.Verbose, "No matching key found in join map for: '{0}'", customJoinData.Key); continue; } @@ -453,7 +454,7 @@ namespace PepperDash.Essentials.Core errorKey = item.Key; break; } - Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); + Debug.LogMessage(LogEventLevel.Information, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); return String.Format(stringFormatter, dataArray["joinNumber"], dataArray["joinSpan"], @@ -505,7 +506,7 @@ namespace PepperDash.Essentials.Core if (attribute == null) return name; name = attribute.Name; - Debug.Console(2, "JoinName Attribute value: {0}", name); + Debug.LogMessage(LogEventLevel.Verbose, "JoinName Attribute value: {0}", name); return name; } } @@ -519,7 +520,7 @@ namespace PepperDash.Essentials.Core public JoinNameAttribute(string name) { - Debug.Console(2, "Setting Attribute Name: {0}", name); + Debug.LogMessage(LogEventLevel.Verbose, "Setting Attribute Name: {0}", name); _Name = name; } diff --git a/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs b/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs index 4afb85bf..a242591e 100644 --- a/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs +++ b/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharp.CrestronDataStore; using PepperDash.Essentials.Core; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.License @@ -69,7 +70,7 @@ namespace PepperDash.Essentials.License { IsValid = isValid; CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid); - Debug.Console(0, "Mock License is{0} valid", IsValid ? "" : " not"); + Debug.LogMessage(LogEventLevel.Information, "Mock License is{0} valid", IsValid ? "" : " not"); LicenseIsValid.FireUpdate(); } diff --git a/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs b/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs index e144ea62..b9978b7c 100644 --- a/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs +++ b/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs @@ -10,6 +10,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; +using Serilog.Events; namespace PepperDash.Essentials.Core.Lighting { @@ -41,7 +42,7 @@ namespace PepperDash.Essentials.Core.Lighting public void SimulateSceneSelect(string sceneName) { - Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName); + Debug.LogMessage(LogEventLevel.Debug, this, "Simulating selection of scene '{0}'", sceneName); var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName)); @@ -89,7 +90,7 @@ namespace PepperDash.Essentials.Core.Lighting } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } return LinkLightingToApi(lightingDevice, trilist, joinMap); @@ -97,9 +98,9 @@ namespace PepperDash.Essentials.Core.Lighting protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap) { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); + Debug.LogMessage(LogEventLevel.Information, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); // GenericLighitng Actions & FeedBack trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); diff --git a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs index 55b458a7..653e2b18 100644 --- a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs +++ b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs @@ -8,6 +8,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.CrestronIO; +using Serilog.Events; namespace PepperDash.Essentials.Core.Privacy @@ -79,14 +80,14 @@ namespace PepperDash.Essentials.Core.Privacy if (greenLed != null) GreenLedRelay = greenLed; else - Debug.Console(0, this, "Unable to add Green LED device"); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to add Green LED device"); var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice; if (redLed != null) RedLedRelay = redLed; else - Debug.Console(0, this, "Unable to add Red LED device"); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to add Red LED device"); AddPostActivationAction(() => { PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; @@ -114,7 +115,7 @@ namespace PepperDash.Essentials.Core.Privacy void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e) { - Debug.Console(1, this, "Privacy mode change: {0}", sender as BoolFeedback); + Debug.LogMessage(LogEventLevel.Debug, this, "Privacy mode change: {0}", sender as BoolFeedback); CheckPrivacyMode(); } @@ -244,7 +245,7 @@ namespace PepperDash.Essentials.Core.Privacy public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new MIcrophonePrivacyController Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new MIcrophonePrivacyController Device"); var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); return new Core.Privacy.MicrophonePrivacyController(dc.Key, props); diff --git a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs index edb4c31b..aad8120d 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using System.ComponentModel; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -232,7 +233,7 @@ namespace PepperDash.Essentials.Core StartErrorTimers(); if (Client.IsConnected) { - //Debug.Console(2, this, "Polling"); + //Debug.LogMessage(LogEventLevel.Verbose, this, "Polling"); if(PollAction != null) PollAction.Invoke(); else @@ -240,7 +241,7 @@ namespace PepperDash.Essentials.Core } else { - Debug.Console(2, this, "Comm not connected"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Comm not connected"); } } } diff --git a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs index 2b5b6ea2..1ffb1b3c 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs @@ -10,6 +10,7 @@ using PepperDash.Core; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using PepperDash.Essentials.Core.Bridges; +using Serilog.Events; namespace PepperDash.Essentials.Core.Monitoring { @@ -61,7 +62,7 @@ namespace PepperDash.Essentials.Core.Monitoring public SystemMonitorController(string key) : base(key) { - Debug.Console(2, this, "Adding SystemMonitorController."); + Debug.LogMessage(LogEventLevel.Verbose, this, "Adding SystemMonitorController."); SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true; @@ -175,11 +176,11 @@ namespace PepperDash.Essentials.Core.Monitoring { EthernetStatusFeedbackCollection = new Dictionary(); - Debug.Console(2, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces); + Debug.LogMessage(LogEventLevel.Verbose, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces); for (short i = 0; i < InitialParametersClass.NumberOfEthernetInterfaces; i++) { - Debug.Console(2, "Creating EthernetStatusFeedback for Interface {0}", i); + Debug.LogMessage(LogEventLevel.Verbose, "Creating EthernetStatusFeedback for Interface {0}", i); var ethernetInterface = new EthernetStatusFeedbacks(i); EthernetStatusFeedbackCollection.Add(i, ethernetInterface); } @@ -260,11 +261,11 @@ namespace PepperDash.Essentials.Core.Monitoring } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(2, this, "Linking API starting at join: {0}", joinStart); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Verbose, this, "Linking API starting at join: {0}", joinStart); TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone.JoinNumber]); TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName.JoinNumber]); @@ -366,8 +367,8 @@ namespace PepperDash.Essentials.Core.Monitoring /// private void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args) { - Debug.Console(2, this, "Program Change Detected for slot: {0}", sender.Number); - Debug.Console(2, this, "Event Type: {0}", args.EventType); + Debug.LogMessage(LogEventLevel.Verbose, this, "Program Change Detected for slot: {0}", sender.Number); + Debug.LogMessage(LogEventLevel.Verbose, this, "Event Type: {0}", args.EventType); var program = ProgramStatusFeedbackCollection[sender.Number]; @@ -400,7 +401,7 @@ namespace PepperDash.Essentials.Core.Monitoring /// private void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args) { - Debug.Console(2, this, "Time Zone Change Detected."); + Debug.LogMessage(LogEventLevel.Verbose, this, "Time Zone Change Detected."); TimeZoneFeedback.FireUpdate(); TimeZoneTextFeedback.FireUpdate(); @@ -425,28 +426,28 @@ namespace PepperDash.Essentials.Core.Monitoring public EthernetStatusFeedbacks(short adapterIndex) { - Debug.Console(2, "Ethernet Information for interface {0}", adapterIndex); - Debug.Console(2, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Ethernet Information for interface {0}", adapterIndex); + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex); - Debug.Console(2, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter( + Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex); HostNameFeedback = new StringFeedback( @@ -585,13 +586,13 @@ namespace PepperDash.Essentials.Core.Monitoring private void GetProgramInfo(object o) { - Debug.Console(2, "Attempting to get program info for slot: {0}", Program.Number); + Debug.LogMessage(LogEventLevel.Verbose, "Attempting to get program info for slot: {0}", Program.Number); string response = null; if (Program.RegistrationState == eProgramRegistrationState.Unregister || Program.OperatingState == eProgramOperatingState.Stop) { - Debug.Console(2, "Program {0} not registered. Setting default values for program information.", + Debug.LogMessage(LogEventLevel.Verbose, "Program {0} not registered. Setting default values for program information.", Program.Number); ProgramInfo = new ProgramInfo(Program.Number) @@ -608,14 +609,14 @@ namespace PepperDash.Essentials.Core.Monitoring if (!success) { - Debug.Console(2, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number); + Debug.LogMessage(LogEventLevel.Verbose, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number); UpdateFeedbacks(); return; } if (response.ToLower().Contains("bad or incomplete")) { - Debug.Console(2, + Debug.LogMessage(LogEventLevel.Verbose, "Program in slot {0} not running. Setting default ProgramInfo for slot: {0}", Program.Number); @@ -665,7 +666,7 @@ namespace PepperDash.Essentials.Core.Monitoring ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n"); ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n"); } - Debug.Console(2, "Program info for slot {0} successfully updated", Program.Number); + Debug.LogMessage(LogEventLevel.Verbose, "Program info for slot {0} successfully updated", Program.Number); UpdateFeedbacks(); } @@ -684,7 +685,7 @@ namespace PepperDash.Essentials.Core.Monitoring public void OnProgramInfoChanged() { - //Debug.Console(1, "Firing ProgramInfoChanged for slot: {0}", Program.Number); + //Debug.LogMessage(LogEventLevel.Debug, "Firing ProgramInfoChanged for slot: {0}", Program.Number); var handler = ProgramInfoChanged; if (handler != null) { @@ -693,24 +694,30 @@ namespace PepperDash.Essentials.Core.Monitoring } private string ParseConsoleData(string data, string line, string startString, string endString) - { + { var outputData = ""; if (data.Length <= 0) return outputData; + if (!data.Contains(line)) + { + return outputData; + } + try { - //Debug.Console(2, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString); + //Debug.LogMessage(LogEventLevel.Verbose, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString); var linePosition = data.IndexOf(line, StringComparison.Ordinal); var startPosition = data.IndexOf(startString, linePosition, StringComparison.Ordinal) + startString.Length; var endPosition = data.IndexOf(endString, startPosition, StringComparison.Ordinal); outputData = data.Substring(startPosition, endPosition - startPosition).Trim(); - //Debug.Console(2, "ParseConsoleData Return: {0}", outputData); + //Debug.LogMessage(LogEventLevel.Verbose, "ParseConsoleData Return: {0}", outputData); } catch (Exception e) { - Debug.Console(1, "Error Parsing Console Data:\r{0}", e); + Debug.LogMessage(LogEventLevel.Error, "Error Parsing Console Data: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, "Stack Trace: {stackTrace}", e.StackTrace); } return outputData; diff --git a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj index de65e50e..fbc03a2e 100644 --- a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj +++ b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs index d3f3d8b3..3e658ea1 100644 --- a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs +++ b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core; +using Serilog.Events; namespace PepperDash.Essentials { @@ -51,12 +52,12 @@ namespace PepperDash.Essentials /// public static void AddProgramAssemblies() { - Debug.Console(2, "Getting Assemblies loaded with Essentials"); + Debug.LogMessage(LogEventLevel.Verbose, "Getting Assemblies loaded with Essentials"); // Get the loaded assembly filenames var appDi = new DirectoryInfo(Global.ApplicationDirectoryPathPrefix); var assemblyFiles = appDi.GetFiles("*.dll"); - Debug.Console(2, "Found {0} Assemblies", assemblyFiles.Length); + Debug.LogMessage(LogEventLevel.Verbose, "Found {0} Assemblies", assemblyFiles.Length); foreach (var fi in assemblyFiles) { @@ -92,11 +93,11 @@ namespace PepperDash.Essentials if (Debug.Level > 1) { - Debug.Console(2, "Loaded Assemblies:"); + Debug.LogMessage(LogEventLevel.Verbose, "Loaded Assemblies:"); foreach (var assembly in LoadedAssemblies) { - Debug.Console(2, "Assembly: {0}", assembly.Name); + Debug.LogMessage(LogEventLevel.Verbose, "Assembly: {0}", assembly.Name); } } } @@ -118,7 +119,7 @@ namespace PepperDash.Essentials /// static LoadedAssembly LoadAssembly(string filePath) { - //Debug.Console(2, "Attempting to load {0}", filePath); + //Debug.LogMessage(LogEventLevel.Verbose, "Attempting to load {0}", filePath); var assembly = Assembly.LoadFrom(filePath); if (assembly != null) { @@ -126,12 +127,12 @@ namespace PepperDash.Essentials var loadedAssembly = new LoadedAssembly(assembly.GetName().Name, assyVersion, assembly); LoadedAssemblies.Add(loadedAssembly); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded assembly '{0}', version {1}", loadedAssembly.Name, loadedAssembly.Version); + Debug.LogMessage(LogEventLevel.Information, "Loaded assembly '{0}', version {1}", loadedAssembly.Name, loadedAssembly.Version); return loadedAssembly; } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to load assembly: '{0}'", filePath); + Debug.LogMessage(LogEventLevel.Information, "Unable to load assembly: '{0}'", filePath); } return null; @@ -168,17 +169,17 @@ namespace PepperDash.Essentials /// True if file already matches loaded assembly file. public static bool CheckIfAssemblyLoaded(string name) { - Debug.Console(2, "Checking if assembly: {0} is loaded...", name); + Debug.LogMessage(LogEventLevel.Verbose, "Checking if assembly: {0} is loaded...", name); var loadedAssembly = LoadedAssemblies.FirstOrDefault(s => s.Name.Equals(name)); if (loadedAssembly != null) { - Debug.Console(2, "Assembly already loaded."); + Debug.LogMessage(LogEventLevel.Verbose, "Assembly already loaded."); return true; } else { - Debug.Console(2, "Assembly not loaded."); + Debug.LogMessage(LogEventLevel.Verbose, "Assembly not loaded."); return false; } } @@ -201,7 +202,7 @@ namespace PepperDash.Essentials /// static void MoveDllAssemblies() { - Debug.Console(0, "Looking for .dll assemblies from plugins folder..."); + Debug.LogMessage(LogEventLevel.Information, "Looking for .dll assemblies from plugins folder..."); var pluginDi = new DirectoryInfo(_pluginDirectory); var pluginFiles = pluginDi.GetFiles("*.dll"); @@ -218,7 +219,7 @@ namespace PepperDash.Essentials { try { - Debug.Console(0, "Found .dll: {0}", pluginFile.Name); + Debug.LogMessage(LogEventLevel.Information, "Found .dll: {0}", pluginFile.Name); if (!CheckIfAssemblyLoaded(pluginFile.Name)) { @@ -229,27 +230,27 @@ namespace PepperDash.Essentials // Check if there is a previous file in the loadedPlugins directory and delete if (File.Exists(filePath)) { - Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); + Debug.LogMessage(LogEventLevel.Information, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); File.Delete(filePath); } // Move the file File.Move(pluginFile.FullName, filePath); - Debug.Console(2, "Moved {0} to {1}", pluginFile.FullName, filePath); + Debug.LogMessage(LogEventLevel.Verbose, "Moved {0} to {1}", pluginFile.FullName, filePath); } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", pluginFile.FullName); + Debug.LogMessage(LogEventLevel.Information, "Skipping assembly: {0}. There is already an assembly with that name loaded.", pluginFile.FullName); } } catch (Exception e) { - Debug.Console(2, "Error with plugin file {0} . Exception: {1}", pluginFile.FullName, e); + Debug.LogMessage(LogEventLevel.Verbose, "Error with plugin file {0} . Exception: {1}", pluginFile.FullName, e); continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here } } - Debug.Console(0, "Done with .dll assemblies"); + Debug.LogMessage(LogEventLevel.Information, "Done with .dll assemblies"); } /// @@ -257,7 +258,7 @@ namespace PepperDash.Essentials /// static void UnzipAndMoveCplzArchives() { - Debug.Console(0, "Looking for .cplz archives from plugins folder..."); + Debug.LogMessage(LogEventLevel.Information, "Looking for .cplz archives from plugins folder..."); var di = new DirectoryInfo(_pluginDirectory); var zFiles = di.GetFiles("*.cplz"); @@ -274,9 +275,9 @@ namespace PepperDash.Essentials Directory.CreateDirectory(_tempDirectory); var tempDi = new DirectoryInfo(_tempDirectory); - Debug.Console(0, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name); + Debug.LogMessage(LogEventLevel.Information, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name); var result = CrestronZIP.Unzip(zfi.FullName, tempDi.FullName); - Debug.Console(0, "UnZip Result: {0}", result.ToString()); + Debug.LogMessage(LogEventLevel.Information, "UnZip Result: {0}", result.ToString()); var tempFiles = tempDi.GetFiles("*.dll"); foreach (var tempFile in tempFiles) @@ -292,22 +293,22 @@ namespace PepperDash.Essentials // Check if there is a previous file in the loadedPlugins directory and delete if (File.Exists(filePath)) { - Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); + Debug.LogMessage(LogEventLevel.Information, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); File.Delete(filePath); } // Move the file File.Move(tempFile.FullName, filePath); - Debug.Console(2, "Moved {0} to {1}", tempFile.FullName, filePath); + Debug.LogMessage(LogEventLevel.Verbose, "Moved {0} to {1}", tempFile.FullName, filePath); } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", tempFile.FullName); + Debug.LogMessage(LogEventLevel.Information, "Skipping assembly: {0}. There is already an assembly with that name loaded.", tempFile.FullName); } } catch (Exception e) { - Debug.Console(2, "Assembly {0} is not a custom assembly. Exception: {1}", tempFile.FullName, e); + Debug.LogMessage(LogEventLevel.Verbose, "Assembly {0} is not a custom assembly. Exception: {1}", tempFile.FullName, e); continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here } } @@ -317,7 +318,7 @@ namespace PepperDash.Essentials zfi.Delete(); } - Debug.Console(0, "Done with .cplz archives"); + Debug.LogMessage(LogEventLevel.Information, "Done with .cplz archives"); } /// @@ -325,11 +326,11 @@ namespace PepperDash.Essentials /// static void LoadPluginAssemblies() { - Debug.Console(0, "Loading assemblies from loadedPlugins folder..."); + Debug.LogMessage(LogEventLevel.Information, "Loading assemblies from loadedPlugins folder..."); var pluginDi = new DirectoryInfo(_loadedPluginsDirectoryPath); var pluginFiles = pluginDi.GetFiles("*.dll"); - Debug.Console(2, "Found {0} plugin assemblies to load", pluginFiles.Length); + Debug.LogMessage(LogEventLevel.Verbose, "Found {0} plugin assemblies to load", pluginFiles.Length); foreach (var pluginFile in pluginFiles) { @@ -338,7 +339,7 @@ namespace PepperDash.Essentials LoadedPluginFolderAssemblies.Add(loadedAssembly); } - Debug.Console(0, "All Plugins Loaded."); + Debug.LogMessage(LogEventLevel.Information, "All Plugins Loaded."); } /// @@ -346,7 +347,7 @@ namespace PepperDash.Essentials /// static void LoadCustomPluginTypes() { - Debug.Console(0, "Loading Custom Plugin Types..."); + Debug.LogMessage(LogEventLevel.Information, "Loading Custom Plugin Types..."); foreach (var loadedAssembly in LoadedPluginFolderAssemblies) { // iteratate this assembly's classes, looking for "LoadPlugin()" methods @@ -357,48 +358,34 @@ namespace PepperDash.Essentials try { types = assy.GetTypes(); - Debug.Console(1, $"Got types for assembly {assy.GetName().Name}"); + Debug.LogMessage(LogEventLevel.Debug, $"Got types for assembly {assy.GetName().Name}"); } catch (TypeLoadException e) { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "Unable to get types for assembly {0}: {1}", + Debug.LogMessage(LogEventLevel.Error, "Unable to get types for assembly {0}: {1}", loadedAssembly.Name, e.Message); - Debug.Console(2, e.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, e.StackTrace); continue; } foreach (var type in types) { try - { - //Debug.Console(0, $"Checking if type {type.Name} is IPluginDeviceFactory"); - - //Debug.Console(0, $"{type.Name} is plugin factory: {typeof(IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract}"); - + { if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract) { var plugin = (IPluginDeviceFactory) Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); LoadCustomPlugin(plugin, loadedAssembly); } - else - { - var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); - var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); - if (loadPlugin != null) - { - LoadCustomLegacyPlugin(type, loadPlugin, loadedAssembly); - } - } } - catch (NotSupportedException e) + catch (NotSupportedException) { - //this happens for dlls that aren't PD dlls, like ports of Mono classes into S#. Swallowing. - + //this happens for dlls that aren't PD dlls, like ports of Mono classes into S#. Swallowing. } catch (Exception e) { - Debug.Console(2, "Load Plugin not found. {0}.{2} is not a plugin factory. Exception: {1}", + Debug.LogMessage(LogEventLevel.Error, "Load Plugin not found. {0}.{2} is not a plugin factory. Exception: {1}", loadedAssembly.Name, e.Message, type.Name); continue; } @@ -407,15 +394,15 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "Error Loading assembly {0}: {1}", + Debug.LogMessage(LogEventLevel.Information, "Error Loading assembly {0}: {1}", loadedAssembly.Name, e.Message); - Debug.Console(2, "{0}", e.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "{0}", e.StackTrace); continue; } } // plugin dll will be loaded. Any classes in plugin should have a static constructor // that registers that class with the Core.DeviceFactory - Debug.Console(0, "Done Loading Custom Plugin Types."); + Debug.LogMessage(LogEventLevel.Information, "Done Loading Custom Plugin Types."); } /// @@ -433,17 +420,17 @@ namespace PepperDash.Essentials if (!passed) { - Debug.Console(0, Debug.ErrorLogLevel.Error, + Debug.LogMessage(LogEventLevel.Information, "\r\n********************\r\n\tPlugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin {1}\r\n********************", plugin.MinimumEssentialsFrameworkVersion, loadedAssembly.Name); return; } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion); + Debug.LogMessage(LogEventLevel.Information, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion); } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name); + Debug.LogMessage(LogEventLevel.Information, "Loading plugin: {0}", loadedAssembly.Name); plugin.LoadTypeFactories(); } @@ -454,14 +441,14 @@ namespace PepperDash.Essentials /// static void LoadCustomLegacyPlugin(CType type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly) { - Debug.Console(2, "LoadPlugin method found in {0}", type.Name); + Debug.LogMessage(LogEventLevel.Verbose, "LoadPlugin method found in {0}", type.Name); var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); if (minimumVersion != null) { - Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); + Debug.LogMessage(LogEventLevel.Verbose, "MinimumEssentialsFrameworkVersion found"); var minimumVersionString = minimumVersion.GetValue(null) as string; @@ -471,25 +458,25 @@ namespace PepperDash.Essentials if (!passed) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); + Debug.LogMessage(LogEventLevel.Information, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); return; } else { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); + Debug.LogMessage(LogEventLevel.Information, "Passed plugin passed dependency check (required version {0})", minimumVersionString); } } else { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); + Debug.LogMessage(LogEventLevel.Information, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); } } else { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); + Debug.LogMessage(LogEventLevel.Information, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading legacy plugin: {0}", loadedAssembly.Name); + Debug.LogMessage(LogEventLevel.Information, "Loading legacy plugin: {0}", loadedAssembly.Name); loadPlugin.Invoke(null, null); } @@ -501,7 +488,7 @@ namespace PepperDash.Essentials { if (Directory.Exists(_pluginDirectory)) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for plugins"); + Debug.LogMessage(LogEventLevel.Information, "Plugins directory found, checking for plugins"); // Deal with any .dll files MoveDllAssemblies(); diff --git a/src/PepperDash.Essentials.Core/Presets/DevicePresets.cs b/src/PepperDash.Essentials.Core/Presets/DevicePresets.cs index 78e7f7e1..74e55a3f 100644 --- a/src/PepperDash.Essentials.Core/Presets/DevicePresets.cs +++ b/src/PepperDash.Essentials.Core/Presets/DevicePresets.cs @@ -10,6 +10,7 @@ using PepperDash.Core; //using SSMono.IO; using PepperDash.Core.WebApi.Presets; +using Serilog.Events; namespace PepperDash.Essentials.Core.Presets { @@ -62,7 +63,7 @@ namespace PepperDash.Essentials.Core.Presets } catch { - Debug.Console(0, "DevicePresets '{0}', not attached to INumericKeypad device. Ignoring", key); + Debug.LogMessage(LogEventLevel.Information, "DevicePresets '{0}', not attached to INumericKeypad device. Ignoring", key); _dialFunctions = null; return; } @@ -112,7 +113,7 @@ namespace PepperDash.Essentials.Core.Presets { _filePath = ListPathPrefix + path; - Debug.Console(2, this, "Setting presets file path to {0}", _filePath); + Debug.LogMessage(LogEventLevel.Verbose, this, "Setting presets file path to {0}", _filePath); LoadChannels(); } @@ -122,7 +123,7 @@ namespace PepperDash.Essentials.Core.Presets { _fileOps.Enter(); - Debug.Console(2, this, "Loading presets from {0}", _filePath); + Debug.LogMessage(LogEventLevel.Verbose, this, "Loading presets from {0}", _filePath); PresetsAreLoaded = false; try { @@ -132,7 +133,7 @@ namespace PepperDash.Essentials.Core.Presets } catch (Exception e) { - Debug.Console(2, this, + Debug.LogMessage(LogEventLevel.Verbose, this, "LoadChannels: Error reading presets file. These presets will be empty:\r '{0}'\r Error:{1}", _filePath, e.Message); // Just save a default empty list @@ -168,7 +169,7 @@ namespace PepperDash.Essentials.Core.Presets } if (_dialFunctions == null) { - Debug.Console(1, "DevicePresets '{0}', not attached to keypad device. Ignoring channel", Key); + Debug.LogMessage(LogEventLevel.Debug, "DevicePresets '{0}', not attached to keypad device. Ignoring channel", Key); return; } diff --git a/src/PepperDash.Essentials.Core/Presets/PresetsListSubpageReferenceListItem.cs b/src/PepperDash.Essentials.Core/Presets/PresetsListSubpageReferenceListItem.cs index 78a9d1bf..c4349414 100644 --- a/src/PepperDash.Essentials.Core/Presets/PresetsListSubpageReferenceListItem.cs +++ b/src/PepperDash.Essentials.Core/Presets/PresetsListSubpageReferenceListItem.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Presets @@ -41,7 +42,7 @@ namespace PepperDash.Essentials.Core.Presets var chan = View.ShowNumbers ? Channel.Channel : ""; Owner.StringInputSig(Index, 2).StringValue = chan; var url = View.Model.ImagesLocalHostPrefix + View.Model.ImagesPathPrefix + Channel.IconUrl; - Debug.Console(2, "icon url={0}", url); + Debug.LogMessage(LogEventLevel.Verbose, "icon url={0}", url); var icon = View.ShowIcon ? url : ""; Owner.StringInputSig(Index, 3).StringValue = icon; } diff --git a/src/PepperDash.Essentials.Core/Queues/GenericQueue.cs b/src/PepperDash.Essentials.Core/Queues/GenericQueue.cs index dc7ff0d4..74b406fc 100644 --- a/src/PepperDash.Essentials.Core/Queues/GenericQueue.cs +++ b/src/PepperDash.Essentials.Core/Queues/GenericQueue.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Threading; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; using Thread = Crestron.SimplSharpPro.CrestronThread.Thread; namespace PepperDash.Essentials.Core.Queues @@ -179,7 +180,7 @@ namespace PepperDash.Essentials.Core.Queues { try { - //Debug.Console(2, this, "Processing queue item: '{0}'", item.ToString()); + //Debug.LogMessage(LogEventLevel.Verbose, this, "Processing queue item: '{0}'", item.ToString()); item.Dispatch(); if (_delayEnabled) @@ -191,13 +192,13 @@ namespace PepperDash.Essentials.Core.Queues } catch (Exception ex) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Caught an exception in the Queue: {1}:{0}", ex.Message, ex); - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Information, this, "Caught an exception in the Queue: {1}:{0}", ex.Message, ex); + Debug.LogMessage(LogEventLevel.Verbose, this, "Stack Trace: {0}", ex.StackTrace); if (ex.InnerException != null) { - Debug.Console(0, this, Debug.ErrorLogLevel.Error, "---\r\n{0}", ex.InnerException.Message); - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.InnerException.StackTrace); + Debug.LogMessage(LogEventLevel.Information, this, "---\r\n{0}", ex.InnerException.Message); + Debug.LogMessage(LogEventLevel.Verbose, this, "Stack Trace: {0}", ex.InnerException.StackTrace); } } } @@ -211,7 +212,7 @@ namespace PepperDash.Essentials.Core.Queues { if (Disposed) { - Debug.Console(1, this, "Queue has been disposed. Enqueuing messages not allowed while program is stopping."); + Debug.LogMessage(LogEventLevel.Debug, this, "Queue has been disposed. Enqueuing messages not allowed while program is stopping."); return; } @@ -243,7 +244,7 @@ namespace PepperDash.Essentials.Core.Queues { using (_waitHandle) { - Debug.Console(2, this, "Disposing..."); + Debug.LogMessage(LogEventLevel.Verbose, this, "Disposing..."); _queue.Enqueue(null); _waitHandle.Set(); _worker.Join(); diff --git a/src/PepperDash.Essentials.Core/Ramps and Increments/NumericalHelpers.cs b/src/PepperDash.Essentials.Core/Ramps and Increments/NumericalHelpers.cs index 50c12ddc..fefeb702 100644 --- a/src/PepperDash.Essentials.Core/Ramps and Increments/NumericalHelpers.cs +++ b/src/PepperDash.Essentials.Core/Ramps and Increments/NumericalHelpers.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core /// public static double Scale(double input, double inMin, double inMax, double outMin, double outMax) { - //Debug.Console(2, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax); + //Debug.LogMessage(LogEventLevel.Verbose, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax); double inputRange = inMax - inMin; @@ -32,7 +32,7 @@ namespace PepperDash.Essentials.Core var output = (((input - inMin) * outputRange) / inputRange) + outMin; - // Debug.Console(2, this, "Scaled output '{0}'", output); + // Debug.LogMessage(LogEventLevel.Verbose, this, "Scaled output '{0}'", output); return output; } diff --git a/src/PepperDash.Essentials.Core/Ramps and Increments/UshortSigIncrementer.cs b/src/PepperDash.Essentials.Core/Ramps and Increments/UshortSigIncrementer.cs index 1a6f3c06..3d29be77 100644 --- a/src/PepperDash.Essentials.Core/Ramps and Increments/UshortSigIncrementer.cs +++ b/src/PepperDash.Essentials.Core/Ramps and Increments/UshortSigIncrementer.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -33,7 +34,7 @@ namespace PepperDash.Essentials.Core RepeatDelay = repeatDelay; RepeatTime = repeatTime; if (SignedMode && (MinValue < -32768 || MaxValue > 32767)) - Debug.Console(1, "UshortSigIncrementer has signed values that exceed range of -32768, 32767"); + Debug.LogMessage(LogEventLevel.Debug, "UshortSigIncrementer has signed values that exceed range of -32768, 32767"); } public void StartUp() diff --git a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs index ba84f949..e96e2a23 100644 --- a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs +++ b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs @@ -14,6 +14,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -63,14 +64,14 @@ namespace PepperDash.Essentials.Core Room.RoomOccupancyIsSet += new EventHandler(RoomOccupancyIsSet); else - Debug.Console(1, this, "Room has no RoomOccupancy object set"); + Debug.LogMessage(LogEventLevel.Debug, this, "Room has no RoomOccupancy object set"); var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion"; FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase; if (FusionRoom == null) - Debug.Console(1, this, "Unable to get Fusion Room from Device Manager with key: {0}", fusionRoomKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to get Fusion Room from Device Manager with key: {0}", fusionRoomKey); }); } @@ -96,14 +97,14 @@ namespace PepperDash.Essentials.Core if (FeatureEnabledTime != null) { - Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "Enabled Time: {0}", FeatureEnabledTime.ToString()); } else - Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime); } catch (Exception e) { - Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e); } try @@ -112,14 +113,14 @@ namespace PepperDash.Essentials.Core if (FeatureDisabledTime != null) { - Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "Disabled Time: {0}", FeatureDisabledTime.ToString()); } else - Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime); } catch (Exception e) { - Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse a DateTime config value \n Error: {1}", e); } if (!PropertiesConfig.EnableRoomOnWhenOccupied) @@ -138,7 +139,7 @@ namespace PepperDash.Essentials.Core FeatureEnabled = CheckIfFeatureShouldBeEnabled(); } else - Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey); } @@ -165,13 +166,13 @@ namespace PepperDash.Essentials.Core { Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange; Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler(RoomIsOccupiedFeedback_OutputChange); - Debug.Console(1, this, "Subscribed to RoomOccupancy status from: '{0}'", Room.Key); + Debug.LogMessage(LogEventLevel.Debug, this, "Subscribed to RoomOccupancy status from: '{0}'", Room.Key); } } void FeatureEventGroup_UserGroupCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "{0}:{1} @ {2}", SchEvent.Name, type, DateTime.Now); + Debug.LogMessage(LogEventLevel.Debug, this, "{0}:{1} @ {2}", SchEvent.Name, type, DateTime.Now); if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration) { @@ -183,13 +184,13 @@ namespace PepperDash.Essentials.Core if (PropertiesConfig.EnableRoomOnWhenOccupied) FeatureEnabled = true; - Debug.Console(1, this, "*****Feature Enabled by event.*****"); + Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Enabled by event.*****"); } else if (SchEvent.Name == FeatureDisableEventName) { FeatureEnabled = false; - Debug.Console(1, this, "*****Feature Disabled by event.*****"); + Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Disabled by event.*****"); } } } @@ -204,7 +205,7 @@ namespace PepperDash.Essentials.Core if(PropertiesConfig.EnableRoomOnWhenOccupied) { - Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime); + Debug.LogMessage(LogEventLevel.Debug, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime); if (DateTime.Now.TimeOfDay.CompareTo(FeatureEnabledTime.TimeOfDay) >= 0 && FeatureDisabledTime.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) > 0) { @@ -216,9 +217,9 @@ namespace PepperDash.Essentials.Core } if(enabled) - Debug.Console(1, this, "*****Feature Enabled*****"); + Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Enabled*****"); else - Debug.Console(1, this, "*****Feature Disabled*****"); + Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Disabled*****"); return enabled; } @@ -230,7 +231,7 @@ namespace PepperDash.Essentials.Core /// void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e) { - Debug.Console(1, this, "RoomIsOccupiedFeeback.OutputChange event fired. e.BoolValue: {0}", e.BoolValue); + Debug.LogMessage(LogEventLevel.Debug, this, "RoomIsOccupiedFeeback.OutputChange event fired. e.BoolValue: {0}", e.BoolValue); if(e.BoolValue) { // Occupancy detected @@ -242,7 +243,7 @@ namespace PepperDash.Essentials.Core if (essentialsRoom != null) { if (!essentialsRoom.OnFeedback.BoolValue) { - Debug.Console(1, this, "Powering Room on to default source"); + Debug.LogMessage(LogEventLevel.Debug, this, "Powering Room on to default source"); var defaultRouteRoom = Room as IRunDefaultPresentRoute; @@ -260,7 +261,7 @@ namespace PepperDash.Essentials.Core void CreateEvent(ScheduledEvent schEvent, string name) { - Debug.Console(1, this, "Adding Event: '{0}'", name); + Debug.LogMessage(LogEventLevel.Debug, this, "Adding Event: '{0}'", name); // Create the event if (schEvent == null) schEvent = new ScheduledEvent(name, FeatureEventGroup); @@ -290,19 +291,19 @@ namespace PepperDash.Essentials.Core else eventTime = FeatureEnabledTime; - Debug.Console(1, this, "eventTime (before recurrence check): {0}", eventTime); + Debug.LogMessage(LogEventLevel.Debug, this, "eventTime (before recurrence check): {0}", eventTime); // Check day of week against recurrence days and move date ahead as necessary to avoid throwing an exception by trying to set the event // start date on a day of the week that doesn't match teh recurrence values while(!SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(eventTime, eventRecurrennce)) { eventTime = eventTime.AddDays(1); - Debug.Console(1, this, "eventTime does not fall on a recurrence weekday. eventTime: {0}", eventTime); + Debug.LogMessage(LogEventLevel.Debug, this, "eventTime does not fall on a recurrence weekday. eventTime: {0}", eventTime); } schEvent.DateAndTime.SetAbsoluteEventTime(eventTime); - Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString()); //CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureEnabledTime, FeatureDisabledTime); @@ -319,7 +320,7 @@ namespace PepperDash.Essentials.Core else schEvent.DateAndTime.SetAbsoluteEventTime(FeatureDisabledTime); - Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString()); CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureDisabledTime, FeatureEnabledTime); @@ -329,10 +330,10 @@ namespace PepperDash.Essentials.Core void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2) { - Debug.Console(1, this, "time1.Hour = {0}", time1.Hour); - Debug.Console(1, this, "time2.Hour = {0}", time2.Hour); - Debug.Console(1, this, "time1.Minute = {0}", time1.Minute); - Debug.Console(1, this, "time2.Minute = {0}", time2.Minute); + Debug.LogMessage(LogEventLevel.Debug, this, "time1.Hour = {0}", time1.Hour); + Debug.LogMessage(LogEventLevel.Debug, this, "time2.Hour = {0}", time2.Hour); + Debug.LogMessage(LogEventLevel.Debug, this, "time1.Minute = {0}", time1.Minute); + Debug.LogMessage(LogEventLevel.Debug, this, "time2.Minute = {0}", time2.Minute); // Calculate the Acknowledge Expiration timer to be the time between the enable and dispable events, less one minute var ackHours = time2.Hour - time1.Hour; @@ -340,14 +341,14 @@ namespace PepperDash.Essentials.Core ackHours = ackHours + 24; var ackMinutes = time2.Minute - time1.Minute; - Debug.Console(1, this, "ackHours = {0}, ackMinutes = {1}", ackHours, ackMinutes); + Debug.LogMessage(LogEventLevel.Debug, this, "ackHours = {0}, ackMinutes = {1}", ackHours, ackMinutes); var ackTotalMinutes = ((ackHours * 60) + ackMinutes) - 1; var ackExpHour = ackTotalMinutes / 60; var ackExpMinutes = ackTotalMinutes % 60; - Debug.Console(1, this, "Acknowledge Expiration Timeout: {0} hours, {1} minutes", ackExpHour, ackExpMinutes); + Debug.LogMessage(LogEventLevel.Debug, this, "Acknowledge Expiration Timeout: {0} hours, {1} minutes", ackExpHour, ackExpMinutes); schEvent.AcknowledgeExpirationTimeout.Hour = (ushort)(ackHours); schEvent.AcknowledgeExpirationTimeout.Minute = (ushort)(ackExpMinutes); @@ -401,12 +402,12 @@ namespace PepperDash.Essentials.Core // Check if existing event has same time and recurrence as config values FeatureEnableEvent = FeatureEventGroup.ScheduledEvents[FeatureEnableEventName]; - Debug.Console(1, this, "Enable event already found in group"); + Debug.LogMessage(LogEventLevel.Debug, this, "Enable event already found in group"); // Check config times and days against DateAndTime of existing event. If different, delete existing event and create new event if(!CheckExistingEventTimeForMatch(FeatureEnableEvent, FeatureEnabledTime) || !CheckExistingEventRecurrenceForMatch(FeatureEnableEvent, CalculateDaysOfWeekRecurrence())) { - Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name); FeatureEventGroup.DeleteEvent(FeatureEnableEvent); FeatureEnableEvent = null; @@ -429,12 +430,12 @@ namespace PepperDash.Essentials.Core else { FeatureDisableEvent = FeatureEventGroup.ScheduledEvents[FeatureDisableEventName]; - Debug.Console(1, this, "Disable event already found in group"); + Debug.LogMessage(LogEventLevel.Debug, this, "Disable event already found in group"); // Check config times against DateAndTime of existing event. If different, delete existing event and create new event if(!CheckExistingEventTimeForMatch(FeatureDisableEvent, FeatureDisabledTime)) { - Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureDisableEvent.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureDisableEvent.Name); FeatureEventGroup.DeleteEvent(FeatureDisableEvent); @@ -484,7 +485,7 @@ namespace PepperDash.Essentials.Core if(PropertiesConfig.EnableRoomOnWhenOccupied) FeatureEnabled = true; - Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled."); + Debug.LogMessage(LogEventLevel.Debug, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled."); } } @@ -499,7 +500,7 @@ namespace PepperDash.Essentials.Core { FeatureEnabled = false; - Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Disabled."); + Debug.LogMessage(LogEventLevel.Debug, this, "RoomOnToDefaultSourceWhenOccupied Feature Disabled."); } } } @@ -549,7 +550,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device"); return new RoomOnToDefaultSourceWhenOccupied(dc); } } diff --git a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs index 820d363f..ac5df758 100644 --- a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs +++ b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -184,7 +185,7 @@ namespace PepperDash.Essentials.Core { _currentScenario.Activate(); - Debug.Console(1, this, "Current Scenario: {0}", _currentScenario.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Current Scenario: {0}", _currentScenario.Name); } var handler = RoomCombinationScenarioChanged; @@ -234,7 +235,7 @@ namespace PepperDash.Essentials.Core { if (isInAutoMode) { - Debug.Console(0, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first."); + Debug.LogMessage(LogEventLevel.Information, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first."); return; } @@ -245,7 +246,7 @@ namespace PepperDash.Essentials.Core // Set the parition states from the scenario manually if (scenario != null) { - Debug.Console(0, this, "Manually setting scenario to '{0}'", scenario.Key); + Debug.LogMessage(LogEventLevel.Information, this, "Manually setting scenario to '{0}'", scenario.Key); foreach (var partitionState in scenario.PartitionStates) { var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionState.PartitionKey)); @@ -254,24 +255,24 @@ namespace PepperDash.Essentials.Core { if (partitionState.PartitionPresent) { - Debug.Console(0, this, "Manually setting state to Present for: '{0}'", partition.Key); + Debug.LogMessage(LogEventLevel.Information, this, "Manually setting state to Present for: '{0}'", partition.Key); partition.SetPartitionStatePresent(); } else { - Debug.Console(0, this, "Manually setting state to Not Present for: '{0}'", partition.Key); + Debug.LogMessage(LogEventLevel.Information, this, "Manually setting state to Not Present for: '{0}'", partition.Key); partition.SetPartitionStateNotPresent(); } } else { - Debug.Console(1, this, "Unable to find partition with key: '{0}'", partitionState.PartitionKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to find partition with key: '{0}'", partitionState.PartitionKey); } } } else { - Debug.Console(1, this, "Unable to find scenario with key: '{0}'", scenarioKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Unable to find scenario with key: '{0}'", scenarioKey); } } @@ -287,7 +288,7 @@ namespace PepperDash.Essentials.Core public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new EssentialsRoomCombiner Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EssentialsRoomCombiner Device"); var props = dc.Properties.ToObject(); diff --git a/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenario.cs b/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenario.cs index a4525999..3a64efb7 100644 --- a/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenario.cs +++ b/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenario.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -56,7 +57,7 @@ namespace PepperDash.Essentials.Core public void Activate() { - Debug.Console(1, "Activating Scenario: '{0}' with {1} action(s) defined", Name, activationActions.Count); + Debug.LogMessage(LogEventLevel.Debug, "Activating Scenario: '{0}' with {1} action(s) defined", Name, activationActions.Count); if (activationActions != null) { @@ -72,7 +73,7 @@ namespace PepperDash.Essentials.Core public void Deactivate() { - Debug.Console(1, "Deactivating Scenario: '{0}' with {1} action(s) defined", Name, deactivationActions.Count); + Debug.LogMessage(LogEventLevel.Debug, "Deactivating Scenario: '{0}' with {1} action(s) defined", Name, deactivationActions.Count); if (deactivationActions != null) { diff --git a/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomConfig.cs b/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomConfig.cs index ebb0f84b..d83e5362 100644 --- a/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomConfig.cs +++ b/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomConfig.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Privacy; +using Serilog.Events; namespace PepperDash.Essentials.Room.Config { @@ -39,7 +40,7 @@ namespace PepperDash.Essentials.Room.Config var microphonePrivacy = props.MicrophonePrivacy; if (microphonePrivacy == null) { - Debug.Console(0, "Cannot create microphone privacy with null properties"); + Debug.LogMessage(LogEventLevel.Information, "Cannot create microphone privacy with null properties"); return null; } // Get the MicrophonePrivacy device from the device manager @@ -47,7 +48,7 @@ namespace PepperDash.Essentials.Room.Config // Set this room as the IPrivacy device if (mP == null) { - Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); + Debug.LogMessage(LogEventLevel.Information, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); return null; } mP.SetPrivacyDevice(room); @@ -56,7 +57,7 @@ namespace PepperDash.Essentials.Room.Config if (behaviour == null) { - Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController"); + Debug.LogMessage(LogEventLevel.Information, "WARNING: No behaviour defined for MicrophonePrivacyController"); return null; } if (behaviour == "trackroomstate") diff --git a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs index 17d151c4..82693d4c 100644 --- a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs +++ b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs @@ -10,6 +10,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -211,14 +212,14 @@ namespace PepperDash.Essentials.Core var mcBridge = DeviceManager.GetDeviceForKey(mcBridgeKey); if (mcBridge == null) { - Debug.Console(1, this, "*********************Mobile Control Bridge Not found for this room."); + Debug.LogMessage(LogEventLevel.Debug, this, "*********************Mobile Control Bridge Not found for this room."); IsMobileControlEnabled = false; return; } else { MobileControlRoomBridge = mcBridge as IMobileControlRoomMessenger; - Debug.Console(1, this, "*********************Mobile Control Bridge found and enabled for this room"); + Debug.LogMessage(LogEventLevel.Debug, this, "*********************Mobile Control Bridge found and enabled for this room"); IsMobileControlEnabled = true; } } @@ -236,7 +237,7 @@ namespace PepperDash.Essentials.Core case eVacancyMode.InShutdownWarning: { StartShutdown(eShutdownType.Vacancy); - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting Down due to vacancy."); + Debug.LogMessage(LogEventLevel.Information, this, "Shutting Down due to vacancy."); break; } default: @@ -259,7 +260,7 @@ namespace PepperDash.Essentials.Core ShutdownType = type; ShutdownPromptTimer.Start(); - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); + Debug.LogMessage(LogEventLevel.Information, this, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount); } public void StartRoomVacancyTimer(eVacancyMode mode) @@ -273,7 +274,7 @@ namespace PepperDash.Essentials.Core VacancyMode = mode; RoomVacancyShutdownTimer.Start(); - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount); + Debug.LogMessage(LogEventLevel.Information, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount); } /// @@ -305,12 +306,12 @@ namespace PepperDash.Essentials.Core { if (statusProvider == null) { - Debug.Console(0, this, "ERROR: Occupancy sensor device is null"); + Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Occupancy sensor device is null"); return; } - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Timeout Minutes from Config is: {0}", timeoutMinutes); + Debug.LogMessage(LogEventLevel.Information, this, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); + Debug.LogMessage(LogEventLevel.Information, this, "Timeout Minutes from Config is: {0}", timeoutMinutes); // If status provider is fusion, set flag to remote if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase) @@ -319,7 +320,7 @@ namespace PepperDash.Essentials.Core if(timeoutMinutes > 0) RoomVacancyShutdownSeconds = timeoutMinutes * 60; - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds); + Debug.LogMessage(LogEventLevel.Information, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds); RoomOccupancy = statusProvider; @@ -351,13 +352,13 @@ namespace PepperDash.Essentials.Core { if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false && AllowVacancyTimerToStart()) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Vacancy Detected"); + Debug.LogMessage(LogEventLevel.Debug, this, "Notice: Vacancy Detected"); // Trigger the timer when the room is vacant StartRoomVacancyTimer(eVacancyMode.InInitialVacancy); } else { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Occupancy Detected"); + Debug.LogMessage(LogEventLevel.Debug, this, "Notice: Occupancy Detected"); // Reset the timer when the room is occupied RoomVacancyShutdownTimer.Cancel(); } diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs index 65a30ff4..605569d2 100644 --- a/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DM; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -65,7 +66,7 @@ namespace PepperDash.Essentials.Core RouteRequests[destination.Key] = routeRequest; - Debug.Console(2, "******************************************************** Device: {0} is cooling down and already has a routing request stored. Storing new route request to route to source key: {1}", destination.Key, routeRequest.Source.Key); + Debug.LogMessage(LogEventLevel.Verbose, "******************************************************** Device: {0} is cooling down and already has a routing request stored. Storing new route request to route to source key: {1}", destination.Key, routeRequest.Source.Key); return; } @@ -79,14 +80,14 @@ namespace PepperDash.Essentials.Core RouteRequests.Add(destination.Key, routeRequest); - Debug.Console(2, "******************************************************** Device: {0} is cooling down. Storing route request to route to source key: {1}", destination.Key, routeRequest.Source.Key); + Debug.LogMessage(LogEventLevel.Verbose, "******************************************************** Device: {0} is cooling down. Storing route request to route to source key: {1}", destination.Key, routeRequest.Source.Key); return; } if (RouteRequests.ContainsKey(destination.Key) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == false) { RouteRequests.Remove(destination.Key); - Debug.Console(2, "******************************************************** Device: {0} is NOT cooling down. Removing stored route request and routing to source key: {1}", destination.Key, routeRequest.Source.Key); + Debug.LogMessage(LogEventLevel.Verbose, "******************************************************** Device: {0} is NOT cooling down. Removing stored route request and routing to source key: {1}", destination.Key, routeRequest.Source.Key); } destination.ReleaseRoute(); @@ -100,7 +101,7 @@ namespace PepperDash.Essentials.Core var newRoute = request.Destination.GetRouteToSource(request.Source, request.SignalType); if (newRoute == null) return; RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute); - Debug.Console(2, request.Destination, "Executing full route"); + Debug.LogMessage(LogEventLevel.Verbose, request.Destination, "Executing full route"); newRoute.ExecuteRoutes(); } @@ -125,7 +126,7 @@ namespace PepperDash.Essentials.Core var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); if (current != null) { - Debug.Console(1, destination, "Releasing current route: {0}", current.Source.Key); + Debug.LogMessage(LogEventLevel.Debug, destination, "Releasing current route: {0}", current.Source.Key); current.ReleaseRoutes(); } } @@ -143,25 +144,25 @@ namespace PepperDash.Essentials.Core // if it's a single signal type, find the route if ((signalType & (eRoutingSignalType.Audio & eRoutingSignalType.Video)) == (eRoutingSignalType.Audio & eRoutingSignalType.Video)) { - Debug.Console(1, destination, "Attempting to build source route from {0}", source.Key); + Debug.LogMessage(LogEventLevel.Debug, destination, "Attempting to build source route from {0}", source.Key); if (!destination.GetRouteToSource(source, null, null, signalType, 0, routeDescr)) routeDescr = null; } // otherwise, audioVideo needs to be handled as two steps. else { - Debug.Console(1, destination, "Attempting to build audio and video routes from {0}", source.Key); + Debug.LogMessage(LogEventLevel.Debug, destination, "Attempting to build audio and video routes from {0}", source.Key); var audioSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Audio, 0, routeDescr); if (!audioSuccess) - Debug.Console(1, destination, "Cannot find audio route to {0}", source.Key); + Debug.LogMessage(LogEventLevel.Debug, destination, "Cannot find audio route to {0}", source.Key); var videoSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Video, 0, routeDescr); if (!videoSuccess) - Debug.Console(1, destination, "Cannot find video route to {0}", source.Key); + Debug.LogMessage(LogEventLevel.Debug, destination, "Cannot find video route to {0}", source.Key); if (!audioSuccess && !videoSuccess) routeDescr = null; } - //Debug.Console(1, destination, "Route{0} discovered", routeDescr == null ? " NOT" : ""); + //Debug.LogMessage(LogEventLevel.Debug, destination, "Route{0} discovered", routeDescr == null ? " NOT" : ""); return routeDescr; } @@ -183,7 +184,7 @@ namespace PepperDash.Essentials.Core eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable) { cycle++; - Debug.Console(2, "GetRouteToSource: {0} {1}--> {2}", cycle, source.Key, destination.Key); + Debug.LogMessage(LogEventLevel.Verbose, "GetRouteToSource: {0} {1}--> {2}", cycle, source.Key, destination.Key); RoutingInputPort goodInputPort = null; var destDevInputTies = TieLineCollection.Default.Where(t => @@ -199,7 +200,7 @@ namespace PepperDash.Essentials.Core } else // no direct-connect. Walk back devices. { - Debug.Console(2, destination, "is not directly connected to {0}. Walking down tie lines", source.Key); + Debug.LogMessage(LogEventLevel.Verbose, destination, "is not directly connected to {0}. Walking down tie lines", source.Key); // No direct tie? Run back out on the inputs' attached devices... // Only the ones that are routing devices @@ -214,12 +215,12 @@ namespace PepperDash.Essentials.Core { var upstreamDeviceOutputPort = inputTieToTry.SourcePort; var upstreamRoutingDevice = upstreamDeviceOutputPort.ParentDevice as IRoutingInputsOutputs; - Debug.Console(2, destination, "Trying to find route on {0}", upstreamRoutingDevice.Key); + Debug.LogMessage(LogEventLevel.Verbose, destination, "Trying to find route on {0}", upstreamRoutingDevice.Key); // Check if this previous device has already been walked if (alreadyCheckedDevices.Contains(upstreamRoutingDevice)) { - Debug.Console(2, destination, "Skipping input {0} on {1}, this was already checked", upstreamRoutingDevice.Key, destination.Key); + Debug.LogMessage(LogEventLevel.Verbose, destination, "Skipping input {0} on {1}, this was already checked", upstreamRoutingDevice.Key, destination.Key); continue; } // haven't seen this device yet. Do it. Pass the output port to the next @@ -228,7 +229,7 @@ namespace PepperDash.Essentials.Core alreadyCheckedDevices, signalType, cycle, routeTable); if (upstreamRoutingSuccess) { - Debug.Console(2, destination, "Upstream device route found"); + Debug.LogMessage(LogEventLevel.Verbose, destination, "Upstream device route found"); goodInputPort = inputTieToTry.DestinationPort; break; // Stop looping the inputs in this cycle } @@ -238,7 +239,7 @@ namespace PepperDash.Essentials.Core // we have a route on corresponding inputPort. *** Do the route *** if (goodInputPort != null) { - //Debug.Console(2, destination, "adding RouteDescriptor"); + //Debug.LogMessage(LogEventLevel.Verbose, destination, "adding RouteDescriptor"); if (outputPortToUse == null) { // it's a sink device @@ -249,12 +250,12 @@ namespace PepperDash.Essentials.Core routeTable.Routes.Add(new RouteSwitchDescriptor (outputPortToUse, goodInputPort)); } else // device is merely IRoutingInputOutputs - Debug.Console(2, destination, " No routing. Passthrough device"); - //Debug.Console(2, destination, "Exiting cycle {0}", cycle); + Debug.LogMessage(LogEventLevel.Verbose, destination, " No routing. Passthrough device"); + //Debug.LogMessage(LogEventLevel.Verbose, destination, "Exiting cycle {0}", cycle); return true; } - Debug.Console(2, destination, "No route found to {0}", source.Key); + Debug.LogMessage(LogEventLevel.Verbose, destination, "No route found to {0}", source.Key); return false; } } @@ -294,7 +295,7 @@ namespace PepperDash.Essentials.Core { if (RouteDescriptors.Any(t => t.Destination == descriptor.Destination)) { - Debug.Console(1, descriptor.Destination, + Debug.LogMessage(LogEventLevel.Debug, descriptor.Destination, "Route to [{0}] already exists in global routes table", descriptor.Source.Key); return; } @@ -350,7 +351,7 @@ namespace PepperDash.Essentials.Core { foreach (var route in Routes) { - Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, "ExecuteRoutes: {0}", route.ToString()); if (route.SwitchingDevice is IRoutingSink) { var device = route.SwitchingDevice as IRoutingSinkWithSwitching; @@ -363,7 +364,7 @@ namespace PepperDash.Essentials.Core { (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); route.OutputPort.InUseTracker.AddUser(Destination, "destination-" + SignalType); - Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); + Debug.LogMessage(LogEventLevel.Verbose, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); } } } @@ -381,7 +382,7 @@ namespace PepperDash.Essentials.Core // Pull the route from the port. Whatever is watching the output's in use tracker is // responsible for responding appropriately. route.OutputPort.InUseTracker.RemoveUser(Destination, "destination-" + SignalType); - Debug.Console(2, "Port {0} releasing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); + Debug.LogMessage(LogEventLevel.Verbose, "Port {0} releasing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); } } } diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs index 5d4fff6c..b6ef0001 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs @@ -187,7 +187,7 @@ namespace PepperDash.Essentials.Core // return null; // var port = sourceDev.OutputPorts[portKey]; // if (port == null) - // Debug.Console(0, "WARNING: Device '{0}' does does not contain output port '{1}'", deviceKey, portKey); + // Debug.LogMessage(LogEventLevel.Information, "WARNING: Device '{0}' does does not contain output port '{1}'", deviceKey, portKey); // return port; //} diff --git a/src/PepperDash.Essentials.Core/Routing/TieLineConfig.cs b/src/PepperDash.Essentials.Core/Routing/TieLineConfig.cs index edb34e7f..1728c20f 100644 --- a/src/PepperDash.Essentials.Core/Routing/TieLineConfig.cs +++ b/src/PepperDash.Essentials.Core/Routing/TieLineConfig.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Config { @@ -29,7 +30,7 @@ namespace PepperDash.Essentials.Core.Config /// null if config data does not match ports, cards or devices public TieLine GetTieLine() { - Debug.Console(0, "Build TieLine: {0}", this); + Debug.LogMessage(LogEventLevel.Information, "Build TieLine: {0}", this); // Get the source device var sourceDev = DeviceManager.GetDeviceForKey(SourceKey) as IRoutingOutputs; if (sourceDev == null) @@ -108,7 +109,7 @@ namespace PepperDash.Essentials.Core.Config void LogError(string msg) { - Debug.Console(1, "WARNING: Cannot create tie line: {0}:\r {1}", msg, this); + Debug.LogMessage(LogEventLevel.Debug, "WARNING: Cannot create tie line: {0}:\r {1}", msg, this); } public override string ToString() diff --git a/src/PepperDash.Essentials.Core/Secrets/CrestronGlobalSecretsProvider.cs b/src/PepperDash.Essentials.Core/Secrets/CrestronGlobalSecretsProvider.cs index 5adefd9e..4614e661 100644 --- a/src/PepperDash.Essentials.Core/Secrets/CrestronGlobalSecretsProvider.cs +++ b/src/PepperDash.Essentials.Core/Secrets/CrestronGlobalSecretsProvider.cs @@ -2,6 +2,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronDataStore; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -46,7 +47,7 @@ namespace PepperDash.Essentials.Core returnCode = CrestronDataStoreStatic.clearGlobal(key); if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) { - Debug.Console(0, this, "Successfully removed secret \"{0}\"", secret); + Debug.LogMessage(LogEventLevel.Information, this, "Successfully removed secret \"{0}\"", secret); return true; } } @@ -56,12 +57,12 @@ namespace PepperDash.Essentials.Core returnCode = CrestronDataStoreStatic.SetGlobalStringValue(key, secret); if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) { - Debug.Console(0, this, "Successfully set secret \"{0}\"", secret); + Debug.LogMessage(LogEventLevel.Information, this, "Successfully set secret \"{0}\"", secret); return true; } } - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to set secret for {0}:{1} - {2}", Key, key, returnCode.ToString()); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to set secret for {0}:{1} - {2}", Key, key, returnCode.ToString()); return false; } @@ -78,10 +79,10 @@ namespace PepperDash.Essentials.Core switch (getErrorCode) { case CrestronDataStore.CDS_ERROR.CDS_SUCCESS: - Debug.Console(2, this, "Secret Successfully retrieved for {0}:{1}", Key, key); + Debug.LogMessage(LogEventLevel.Verbose, this, "Secret Successfully retrieved for {0}:{1}", Key, key); return new CrestronSecret(key, mySecret, this); default: - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to retrieve secret for {0}:{1} - {2}", + Debug.LogMessage(LogEventLevel.Information, this, "Unable to retrieve secret for {0}:{1} - {2}", Key, key, getErrorCode.ToString()); return null; } diff --git a/src/PepperDash.Essentials.Core/Secrets/CrestronLocalSecretsProvider.cs b/src/PepperDash.Essentials.Core/Secrets/CrestronLocalSecretsProvider.cs index 955c875c..6c355d30 100644 --- a/src/PepperDash.Essentials.Core/Secrets/CrestronLocalSecretsProvider.cs +++ b/src/PepperDash.Essentials.Core/Secrets/CrestronLocalSecretsProvider.cs @@ -3,6 +3,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronDataStore; using PepperDash.Core; using Crestron.SimplSharpPro; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -47,7 +48,7 @@ namespace PepperDash.Essentials.Core returnCode = CrestronDataStoreStatic.clearLocal(key); if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) { - Debug.Console(0, this, "Successfully removed secret \"{0}\"", secret); + Debug.LogMessage(LogEventLevel.Information, this, "Successfully removed secret \"{0}\"", secret); return true; } } @@ -57,12 +58,12 @@ namespace PepperDash.Essentials.Core returnCode = CrestronDataStoreStatic.SetLocalStringValue(key, secret); if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) { - Debug.Console(0, this, "Successfully set secret \"{0}\"", secret); + Debug.LogMessage(LogEventLevel.Information, this, "Successfully set secret \"{0}\"", secret); return true; } } - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to set secret for {0}:{1} - {2}", Key, key, returnCode.ToString()); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to set secret for {0}:{1} - {2}", Key, key, returnCode.ToString()); return false; } @@ -79,10 +80,10 @@ namespace PepperDash.Essentials.Core switch (getErrorCode) { case CrestronDataStore.CDS_ERROR.CDS_SUCCESS: - Debug.Console(2, this, "Secret Successfully retrieved for {0}:{1}", Key, key); + Debug.LogMessage(LogEventLevel.Verbose, this, "Secret Successfully retrieved for {0}:{1}", Key, key); return new CrestronSecret(key, mySecret, this); default: - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to retrieve secret for {0}:{1} - {2}", + Debug.LogMessage(LogEventLevel.Information, this, "Unable to retrieve secret for {0}:{1} - {2}", Key, key, getErrorCode.ToString()); return null; } diff --git a/src/PepperDash.Essentials.Core/Secrets/SecretsManager.cs b/src/PepperDash.Essentials.Core/Secrets/SecretsManager.cs index b8563c3b..8309b7e9 100644 --- a/src/PepperDash.Essentials.Core/Secrets/SecretsManager.cs +++ b/src/PepperDash.Essentials.Core/Secrets/SecretsManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core if (secret == null) { - Debug.Console(1, "SecretsManager unable to retrieve SecretProvider with the key '{0}'", key); + Debug.LogMessage(LogEventLevel.Debug, "SecretsManager unable to retrieve SecretProvider with the key '{0}'", key); } return secret; } @@ -147,10 +148,10 @@ namespace PepperDash.Essentials.Core if (!Secrets.ContainsKey(key)) { Secrets.Add(key, provider); - Debug.Console(1, "Secrets provider '{0}' added to SecretsManager", key); + Debug.LogMessage(LogEventLevel.Debug, "Secrets provider '{0}' added to SecretsManager", key); return; } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key ); + Debug.LogMessage(LogEventLevel.Information, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key ); } /// @@ -164,16 +165,16 @@ namespace PepperDash.Essentials.Core if (!Secrets.ContainsKey(key)) { Secrets.Add(key, provider); - Debug.Console(1, "Secrets provider '{0}' added to SecretsManager", key); + Debug.LogMessage(LogEventLevel.Debug, "Secrets provider '{0}' added to SecretsManager", key); return; } if (overwrite) { Secrets.Add(key, provider); - Debug.Console(1, Debug.ErrorLogLevel.Notice, "Provider with the key '{0}' already exists in secrets. Overwriting with new secrets provider.", key); + Debug.LogMessage(LogEventLevel.Debug, "Provider with the key '{0}' already exists in secrets. Overwriting with new secrets provider.", key); return; } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key); + Debug.LogMessage(LogEventLevel.Information, "Unable to add Provider '{0}' to Secrets. Provider with that key already exists", key); } private static void SetSecretProcess(string cmd) @@ -274,7 +275,7 @@ namespace PepperDash.Essentials.Core { var secretPresent = provider.TestSecret(key); - Debug.Console(2, provider, "SecretsProvider {0} {1} contain a secret entry for {2}", provider.Key, secretPresent ? "does" : "does not", key); + Debug.LogMessage(LogEventLevel.Verbose, provider, "SecretsProvider {0} {1} contain a secret entry for {2}", provider.Key, secretPresent ? "does" : "does not", key); if (!secretPresent) return @@ -294,7 +295,7 @@ namespace PepperDash.Essentials.Core { var secretPresent = provider.TestSecret(key); - Debug.Console(2, provider, "SecretsProvider {0} {1} contain a secret entry for {2}", provider.Key, secretPresent ? "does" : "does not", key); + Debug.LogMessage(LogEventLevel.Verbose, provider, "SecretsProvider {0} {1} contain a secret entry for {2}", provider.Key, secretPresent ? "does" : "does not", key); if (secretPresent) return diff --git a/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectDynamicList.cs b/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectDynamicList.cs index bf73ba1b..5d768803 100644 --- a/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectDynamicList.cs +++ b/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectDynamicList.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.SmartObjects @@ -47,12 +48,12 @@ namespace PepperDash.Essentials.Core.SmartObjects var c = Count; NameSigOffset = nameSigOffset; MaxCount = SmartObject.BooleanOutput.Count(s => s.Name.EndsWith("Pressed")); - //Debug.Console(2, "Smart object {0} has {1} max", so.ID, MaxCount); + //Debug.LogMessage(LogEventLevel.Verbose, "Smart object {0} has {1} max", so.ID, MaxCount); } catch { var msg = string.Format("SmartObjectDynamicList: Smart Object {0:X2}-{1} is not a dynamic list. Ignoring", so.Device.ID, so.ID); - Debug.Console(0, Debug.ErrorLogLevel.Error, msg); + Debug.LogMessage(LogEventLevel.Information, msg); } } @@ -72,7 +73,7 @@ namespace PepperDash.Essentials.Core.SmartObjects //} //catch(Exception e) //{ - // Debug.Console(1, "Cannot set Dynamic List item {0} on smart object {1}", index, SmartObject.ID); + // Debug.LogMessage(LogEventLevel.Debug, "Cannot set Dynamic List item {0} on smart object {1}", index, SmartObject.ID); // ErrorLog.Warn(e.ToString()); //} } @@ -120,7 +121,7 @@ namespace PepperDash.Essentials.Core.SmartObjects /// public void ClearActions() { - Debug.Console(2, "SO CLEAR"); + Debug.LogMessage(LogEventLevel.Verbose, "SO CLEAR"); for(ushort i = 1; i <= MaxCount; i++) SmartObject.BooleanOutput[string.Format("Item {0} Pressed", i)].UserObject = null; } diff --git a/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectHelperBase.cs b/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectHelperBase.cs index 6fadf491..23bf4530 100644 --- a/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectHelperBase.cs +++ b/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectHelperBase.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.SmartObjects { @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.SmartObjects if (SmartObject.BooleanOutput.Contains(name)) return SmartObject.BooleanOutput[name]; else - Debug.Console(0, "WARNING: Cannot get signal. Smart object {0} on trilist {1:x2} does not contain signal '{2}'", + Debug.LogMessage(LogEventLevel.Information, "WARNING: Cannot get signal. Smart object {0} on trilist {1:x2} does not contain signal '{2}'", SmartObject.ID, SmartObject.Device.ID, name); return null; } @@ -61,7 +62,7 @@ namespace PepperDash.Essentials.Core.SmartObjects SmartObject.BooleanOutput[name].UserObject = a; else { - Debug.Console(0, "WARNING: Cannot set action. Smart object {0} on trilist {1:x2} does not contain signal '{2}'", + Debug.LogMessage(LogEventLevel.Information, "WARNING: Cannot set action. Smart object {0} on trilist {1:x2} does not contain signal '{2}'", SmartObject.ID, SmartObject.Device.ID, name); } } diff --git a/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs b/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs index e8c49b40..4e0e1f5e 100644 --- a/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs +++ b/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SourceListSubpageReferenceList.cs @@ -83,7 +83,7 @@ // // Handler to route source changes into list feedback // void CurrentRoom_PresentationSourceChange(object sender, EssentialsRoomSourceChangeEventArgs args) // { -// Debug.Console(2, "SRL received source change"); +// Debug.LogMessage(LogEventLevel.Verbose, "SRL received source change"); // ClearPresentationSourceFb(args.OldSource); // SetPresentationSourceFb(args.NewSource); // } @@ -131,7 +131,7 @@ // // Should be able to see if there is not enough buttons right here // if (nameSig == null) // { -// Debug.Console(0, "ERROR: Item {0} does not exist on source list SRL", index); +// Debug.LogMessage(LogEventLevel.Information, "ERROR: Item {0} does not exist on source list SRL", index); // return; // } // nameSig.StringValue = srcDevice.Name; @@ -148,7 +148,7 @@ // var status = videoDev.GetVideoStatuses(); // if (status != null) // { -// Debug.Console(1, "Linking {0} video status to SRL", videoDev.Key); +// Debug.LogMessage(LogEventLevel.Debug, "Linking {0} video status to SRL", videoDev.Key); // videoDev.GetVideoStatuses().VideoSyncFeedback.LinkInputSig(owner.BoolInputSig(index, 3)); // } // } diff --git a/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SubpageReferenceList.cs b/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SubpageReferenceList.cs index 711a3cde..f92e182b 100644 --- a/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SubpageReferenceList.cs +++ b/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferencList/SubpageReferenceList.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.UI; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core @@ -53,7 +54,7 @@ namespace PepperDash.Essentials.Core // Fail cleanly if not defined if (triList.SmartObjects == null || triList.SmartObjects.Count == 0) { - Debug.Console(0, "TriList {0:X2} Smart objects have not been loaded", triList.ID, smartObjectId); + Debug.LogMessage(LogEventLevel.Information, "TriList {0:X2} Smart objects have not been loaded", triList.ID, smartObjectId); return; } if (triList.SmartObjects.TryGetValue(smartObjectId, out obj)) @@ -68,13 +69,13 @@ namespace PepperDash.Essentials.Core // Count the enable lines to see what max items is MaxDefinedItems = (ushort)SRL.BooleanInput .Where(s => s.Name.Contains("Enable")).Count(); - Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems); + Debug.LogMessage(LogEventLevel.Verbose, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems); SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange); SRL.SigChange += new SmartObjectSigChangeEventHandler(SRL_SigChange); } else - Debug.Console(0, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded", + Debug.LogMessage(LogEventLevel.Information, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded", triList.ID, smartObjectId); } diff --git a/src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs b/src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs index 763a4fe1..28bd6811 100644 --- a/src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs +++ b/src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -49,7 +50,7 @@ namespace PepperDash.Essentials.Core var timeSpan = FinishTime - DateTime.Now; - Debug.Console(2, this, + Debug.LogMessage(LogEventLevel.Verbose, this, "timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds); diff --git a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs index fe72247d..968c10bb 100644 --- a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs +++ b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs @@ -11,6 +11,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core.Timers @@ -62,14 +63,14 @@ namespace PepperDash.Essentials.Core.Timers public void StartTimer() { CleanUpTimer(); - Debug.Console(0, this, "Starting Timer"); + Debug.LogMessage(LogEventLevel.Information, this, "Starting Timer"); _timer = new CTimer(TimerElapsedCallback, GetActionFromConfig(eRetriggerableTimerEvents.Elapsed), _timerIntervalMs, _timerIntervalMs); } public void StopTimer() { - Debug.Console(0, this, "Stopping Timer"); + Debug.LogMessage(LogEventLevel.Information, this, "Stopping Timer"); _timer.Stop(); ExecuteAction(GetActionFromConfig(eRetriggerableTimerEvents.Stopped)); @@ -90,11 +91,11 @@ namespace PepperDash.Essentials.Core.Timers /// private void TimerElapsedCallback(object action) { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Timer Elapsed. Executing Action"); + Debug.LogMessage(LogEventLevel.Debug, this, "Timer Elapsed. Executing Action"); if (action == null) { - Debug.Console(1, this, "Timer elapsed but unable to execute action. Action is null."); + Debug.LogMessage(LogEventLevel.Debug, this, "Timer elapsed but unable to execute action. Action is null."); return; } @@ -103,7 +104,7 @@ namespace PepperDash.Essentials.Core.Timers ExecuteAction(devAction); else { - Debug.Console(2, this, "Unable to cast action as DeviceActionWrapper. Cannot Execute"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Unable to cast action as DeviceActionWrapper. Cannot Execute"); } } @@ -119,7 +120,7 @@ namespace PepperDash.Essentials.Core.Timers } catch (Exception e) { - Debug.Console(2, this, "Error Executing Action: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error Executing Action: {0}", e); } //finally // Not sure this is needed //{ @@ -169,7 +170,7 @@ namespace PepperDash.Essentials.Core.Timers public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new RetriggerableTimer Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new RetriggerableTimer Device"); return new RetriggerableTimer(dc.Key, dc); } diff --git a/src/PepperDash.Essentials.Core/Touchpanels/ModalDialog.cs b/src/PepperDash.Essentials.Core/Touchpanels/ModalDialog.cs index 3b2ff89b..4dbe7158 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/ModalDialog.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/ModalDialog.cs @@ -2,6 +2,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core { @@ -177,7 +178,7 @@ namespace PepperDash.Essentials.Core } catch { - Debug.Console(1, "Error Waking Panel. Maybe testing with Xpanel?"); + Debug.LogMessage(LogEventLevel.Debug, "Error Waking Panel. Maybe testing with Xpanel?"); } } diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs index 2f6074dd..c75a95b4 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs @@ -4,6 +4,7 @@ using System.Globalization; using Crestron.SimplSharpPro; using Newtonsoft.Json; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials.Core.Touchpanels { @@ -23,14 +24,14 @@ namespace PepperDash.Essentials.Core.Touchpanels _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; if (_touchpanel == null) { - Debug.Console(1, this, "Failed to construct MPC3 Touchpanel Controller with key {0}, check configuration", key); + Debug.LogMessage(LogEventLevel.Debug, this, "Failed to construct MPC3 Touchpanel Controller with key {0}, check configuration", key); return; } if (_touchpanel.Registerable) { var registrationResponse = _touchpanel.Register(); - Debug.Console(0, this, "touchpanel registration response: {0}", registrationResponse); + Debug.LogMessage(LogEventLevel.Information, this, "touchpanel registration response: {0}", registrationResponse); } _touchpanel.BaseEvent += _touchpanel_BaseEvent; @@ -40,7 +41,7 @@ namespace PepperDash.Essentials.Core.Touchpanels _buttons = buttons; if (_buttons == null) { - Debug.Console(1, this, + Debug.LogMessage(LogEventLevel.Debug, this, "Button properties are null, failed to setup MPC3 Touch Controller, check configuration"); return; } @@ -67,7 +68,7 @@ namespace PepperDash.Essentials.Core.Touchpanels { if (config == null) { - Debug.Console(1, this, "Button '{0}' config is null, unable to initialize", key); + Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' config is null, unable to initialize", key); return; } @@ -139,7 +140,7 @@ namespace PepperDash.Essentials.Core.Touchpanels } } - Debug.Console(0, this, "InitializeButton: key-'{0}' enabledFb-'{1}', disabledFb-'{2}'", + Debug.LogMessage(LogEventLevel.Information, this, "InitializeButton: key-'{0}' enabledFb-'{1}', disabledFb-'{2}'", key, enabledFb ?? (object)"null", disabledFb ?? (object)"null"); } @@ -150,11 +151,11 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void InitializeButtonFeedback(string key, KeypadButton config) { - //Debug.Console(1, this, "Initializing button '{0}' feedback...", key); + //Debug.LogMessage(LogEventLevel.Debug, this, "Initializing button '{0}' feedback...", key); if (config == null) { - Debug.Console(1, this, "Button '{0}' config is null, skipping.", key); + Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' config is null, skipping.", key); return; } @@ -165,7 +166,7 @@ namespace PepperDash.Essentials.Core.Touchpanels var buttonFeedback = config.Feedback; if (buttonFeedback == null || string.IsNullOrEmpty(buttonFeedback.DeviceKey)) { - Debug.Console(1, this, "Button '{0}' feedback not configured, skipping.", + Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback not configured, skipping.", key); return; } @@ -177,7 +178,7 @@ namespace PepperDash.Essentials.Core.Touchpanels var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; if (device == null) { - Debug.Console(1, this, "Button '{0}' feedback deviceKey '{1}' not found.", + Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback deviceKey '{1}' not found.", key, buttonFeedback.DeviceKey); return; } @@ -185,13 +186,13 @@ namespace PepperDash.Essentials.Core.Touchpanels deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); if (deviceFeedback == null) { - Debug.Console(1, this, "Button '{0}' feedbackName property '{1}' not found.", + Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedbackName property '{1}' not found.", key, buttonFeedback.FeedbackName); return; } // TODO [ ] verify if this can replace the current method - //Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); + //Debug.LogMessage(LogEventLevel.Information, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); //switch (feedback.GetType().Name.ToLower()) //{ // case("boolfeedback"): @@ -210,11 +211,11 @@ namespace PepperDash.Essentials.Core.Touchpanels } catch (Exception ex) { - Debug.Console(1, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception Message: {0}", + Debug.LogMessage(LogEventLevel.Debug, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception Message: {0}", ex.Message, key, buttonFeedback.DeviceKey); - Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception StackTrace: {0}", + Debug.LogMessage(LogEventLevel.Verbose, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception StackTrace: {0}", ex.StackTrace, key, buttonFeedback.DeviceKey); - if (ex.InnerException != null) Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') InnerException: {0}", + if (ex.InnerException != null) Debug.LogMessage(LogEventLevel.Verbose, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') InnerException: {0}", ex.InnerException, key, buttonFeedback.DeviceKey); return; @@ -276,12 +277,12 @@ namespace PepperDash.Essentials.Core.Touchpanels private void _touchpanel_BaseEvent(GenericBase device, BaseEventArgs args) { - Debug.Console(1, this, "BaseEvent: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + Debug.LogMessage(LogEventLevel.Debug, this, "BaseEvent: eventId-'{0}', index-'{1}'", args.EventId, args.Index); } private void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) { - Debug.Console(1, this, "ButtonStateChange: buttonNumber-'{0}' buttonName-'{1}', buttonState-'{2}'", args.Button.Number, args.Button.Name, args.NewButtonState); + Debug.LogMessage(LogEventLevel.Debug, this, "ButtonStateChange: buttonNumber-'{0}' buttonName-'{1}', buttonState-'{2}'", args.Button.Number, args.Button.Name, args.NewButtonState); var type = args.NewButtonState.ToString(); if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) @@ -296,7 +297,7 @@ namespace PepperDash.Essentials.Core.Touchpanels private void _touchpanel_PanelStateChange(GenericBase device, BaseEventArgs args) { - Debug.Console(1, this, "PanelStateChange: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + Debug.LogMessage(LogEventLevel.Debug, this, "PanelStateChange: eventId-'{0}', index-'{1}'", args.EventId, args.Index); } /// @@ -307,7 +308,7 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void Press(string buttonKey, string type) { - Debug.Console(2, this, "Press: buttonKey-'{0}', type-'{1}'", buttonKey, type); + Debug.LogMessage(LogEventLevel.Verbose, this, "Press: buttonKey-'{0}', type-'{1}'", buttonKey, type); // TODO: In future, consider modifying this to generate actions at device activation time // to prevent the need to dynamically call the method via reflection on each button press diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs index e0f44046..539bb9d4 100644 --- a/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs +++ b/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs @@ -5,6 +5,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Presets; +using Serilog.Events; namespace PepperDash.Essentials.Core.PageManagers { @@ -164,7 +165,7 @@ namespace PepperDash.Essentials.Core.PageManagers // Bad config case else { - Debug.Console(1, stb, "WARNING: Not configured to show any UI elements"); + Debug.LogMessage(LogEventLevel.Debug, stb, "WARNING: Not configured to show any UI elements"); FixedVisibilityJoins = new uint[] { 10091 }; } diff --git a/src/PepperDash.Essentials.Core/UI/TouchpanelBase.cs b/src/PepperDash.Essentials.Core/UI/TouchpanelBase.cs index 00cdc28e..1d83ea5b 100644 --- a/src/PepperDash.Essentials.Core/UI/TouchpanelBase.cs +++ b/src/PepperDash.Essentials.Core/UI/TouchpanelBase.cs @@ -9,6 +9,7 @@ using PepperDash.Core; using Crestron.SimplSharpPro.UI; using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharpPro; +using Serilog.Events; namespace PepperDash.Essentials.Core.UI { @@ -33,7 +34,7 @@ namespace PepperDash.Essentials.Core.UI if (panel == null) { - Debug.Console(0, this, "Panel is not valid. Touchpanel class WILL NOT work correctly"); + Debug.LogMessage(LogEventLevel.Information, this, "Panel is not valid. Touchpanel class WILL NOT work correctly"); return; } @@ -55,19 +56,19 @@ namespace PepperDash.Essentials.Core.UI AddPreActivationAction(() => { if (Panel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason); + Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason); // Give up cleanly if SGD is not present. var sgdName = Global.FilePathPrefix + "sgd" + Global.DirectorySeparator + _config.SgdFile; if (!File.Exists(sgdName)) { - Debug.Console(0, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName); + Debug.LogMessage(LogEventLevel.Information, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName); sgdName = Global.ApplicationDirectoryPathPrefix + Global.DirectorySeparator + "SGD" + Global.DirectorySeparator + _config.SgdFile; if (!File.Exists(sgdName)) { - Debug.Console(0, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName); return; } } @@ -154,7 +155,7 @@ namespace PepperDash.Essentials.Core.UI private void Panel_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { - Debug.Console(5, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + Debug.LogMessage(LogEventLevel.Verbose, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); var uo = args.Sig.UserObject; if (uo is Action) (uo as Action)(args.Sig.BoolValue); diff --git a/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs b/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs index f0c2bfc2..5c519f60 100644 --- a/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs +++ b/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs @@ -12,6 +12,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Core.Utilities { @@ -51,11 +52,11 @@ namespace PepperDash.Essentials.Core.Utilities { if (_worker !=null && _worker.ThreadState == Thread.eThreadStates.ThreadRunning) { - Debug.Console(1, this, "Thread already running. Cannot Start Sequence"); + Debug.LogMessage(LogEventLevel.Debug, this, "Thread already running. Cannot Start Sequence"); return; } - Debug.Console(1, this, "Starting Action Sequence"); + Debug.LogMessage(LogEventLevel.Debug, this, "Starting Action Sequence"); _allowActionsToExecute = true; AddActionsToQueue(); _worker = new Thread(ProcessActions, null, Thread.eThreadStartOptions.Running); @@ -66,7 +67,7 @@ namespace PepperDash.Essentials.Core.Utilities /// public void StopSequence() { - Debug.Console(1, this, "Stopping Action Sequence"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Action Sequence"); _allowActionsToExecute = false; _worker.Abort(); } @@ -76,7 +77,7 @@ namespace PepperDash.Essentials.Core.Utilities /// private void AddActionsToQueue() { - Debug.Console(1, this, "Adding {0} actions to queue", _propertiesConfig.ActionSequence.Count); + Debug.LogMessage(LogEventLevel.Debug, this, "Adding {0} actions to queue", _propertiesConfig.ActionSequence.Count); for (int i = 0; i < _propertiesConfig.ActionSequence.Count; i++) { @@ -115,7 +116,7 @@ namespace PepperDash.Essentials.Core.Utilities } catch (Exception e) { - Debug.Console(2, this, "Error Executing Action: {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error Executing Action: {0}", e); } } } @@ -152,7 +153,7 @@ namespace PepperDash.Essentials.Core.Utilities public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new ActionSequence Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new ActionSequence Device"); return new ActionSequence(dc.Key, dc); } diff --git a/src/PepperDash.Essentials.Core/Web/EssentialsWebApi.cs b/src/PepperDash.Essentials.Core/Web/EssentialsWebApi.cs index 165b9c21..eb5fee37 100644 --- a/src/PepperDash.Essentials.Core/Web/EssentialsWebApi.cs +++ b/src/PepperDash.Essentials.Core/Web/EssentialsWebApi.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp.WebScripting; using PepperDash.Core; using PepperDash.Core.Web; using PepperDash.Essentials.Core.Web.RequestHandlers; +using Serilog.Events; namespace PepperDash.Essentials.Core.Web { @@ -206,7 +207,7 @@ namespace PepperDash.Essentials.Core.Web if (response.Contains("OFF")) return; var is4Series = eCrestronSeries.Series4 == (Global.ProcessorSeries & eCrestronSeries.Series4); - Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on {0} Appliance", is4Series ? "4-series" : "3-series"); + Debug.LogMessage(LogEventLevel.Verbose, "Starting Essentials Web API on {0} Appliance", is4Series ? "4-series" : "3-series"); _server.Start(); @@ -216,7 +217,7 @@ namespace PepperDash.Essentials.Core.Web } // Automatically start CWS when running on a server (Linux OS, Virtual Control) - Debug.Console(DebugTrace, Debug.ErrorLogLevel.Notice, "Starting Essentials Web API on Virtual Control Server"); + Debug.LogMessage(LogEventLevel.Verbose, "Starting Essentials Web API on Virtual Control Server"); _server.Start(); @@ -232,7 +233,7 @@ namespace PepperDash.Essentials.Core.Web /// public void GetPaths() { - Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); + Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", new String('-', 50)); var currentIp = CrestronEthernetHelper.GetEthernetParameter( CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); @@ -244,20 +245,20 @@ namespace PepperDash.Essentials.Core.Web ? string.Format("http(s)://{0}/VirtualControl/Rooms/{1}/cws{2}", hostname, InitialParametersClass.RoomId, BasePath) : string.Format("http(s)://{0}/cws{1}", currentIp, BasePath); - Debug.Console(DebugTrace, this, "Server:{0}", path); + Debug.LogMessage(LogEventLevel.Verbose, this, "Server:{0}", path); var routeCollection = _server.GetRouteCollection(); if (routeCollection == null) { - Debug.Console(DebugTrace, this, "Server route collection is null"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Server route collection is null"); return; } - Debug.Console(DebugTrace, this, "Configured Routes:"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Configured Routes:"); foreach (var route in routeCollection) { - Debug.Console(DebugTrace, this, "{0}: {1}/{2}", route.Name, path, route.Url); + Debug.LogMessage(LogEventLevel.Verbose, this, "{0}: {1}/{2}", route.Name, path, route.Url); } - Debug.Console(DebugTrace, this, "{0}", new String('-', 50)); + Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", new String('-', 50)); } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/EssentialsWebApiFactory.cs b/src/PepperDash.Essentials.Core/Web/EssentialsWebApiFactory.cs index 5c44d3b3..d0610ede 100644 --- a/src/PepperDash.Essentials.Core/Web/EssentialsWebApiFactory.cs +++ b/src/PepperDash.Essentials.Core/Web/EssentialsWebApiFactory.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using PepperDash.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; namespace PepperDash.Essentials.Core.Web { @@ -13,12 +14,12 @@ namespace PepperDash.Essentials.Core.Web public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Essentials Web API Server"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Essentials Web API Server"); var props = dc.Properties.ToObject(); if (props != null) return new EssentialsWebApi(dc.Key, dc.Name, props); - Debug.Console(1, "Factory failed to create new Essentials Web API Server"); + Debug.LogMessage(LogEventLevel.Debug, "Factory failed to create new Essentials Web API Server"); return null; } } diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs index 9de58657..80c7bfbe 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs @@ -4,6 +4,7 @@ using Crestron.SimplSharpPro.EthernetCommunication; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; +using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; @@ -44,7 +45,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers if (!Debug.WebsocketSink.IsRunning) { - Debug.Console(0, "Starting WS Server"); + Debug.LogMessage(LogEventLevel.Information, "Starting WS Server"); // Generate a random port within a specified range port = new Random().Next(65435, 65535); // Start the WS Server @@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers url = Debug.WebsocketSink.Url }; - Debug.Console(0, "Debug Session URL: {0}", url); + Debug.LogMessage(LogEventLevel.Information, "Debug Session URL: {0}", url); // Return the port number with the full url of the WS Server var res = JsonConvert.SerializeObject(data); @@ -73,7 +74,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception e) { - Debug.Console(0, "Error: {0}", e); + Debug.LogMessage(LogEventLevel.Information, "Error: {0}", e); } } @@ -89,7 +90,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.StatusDescription = "OK"; context.Response.End(); - Debug.Console(0, "Websocket Debug Session Stopped"); + Debug.LogMessage(LogEventLevel.Information, "Websocket Debug Session Stopped"); } } diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs index 5c4f33a2..a78b88ce 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs @@ -2,6 +2,7 @@ using Crestron.SimplSharp.WebScripting; using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; +using Serilog.Events; namespace PepperDash.Essentials.Core.Web.RequestHandlers { @@ -53,9 +54,9 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception ex) { - Debug.Console(1, "Exception Message: {0}", ex.Message); - Debug.Console(2, "Exception Stack Trace: {0}", ex.StackTrace); - if(ex.InnerException != null) Debug.Console(2, "Exception Inner: {0}", ex.InnerException); + Debug.LogMessage(LogEventLevel.Error, "Exception Message: {0}", ex.Message); + Debug.LogMessage(LogEventLevel.Verbose, "Exception Stack Trace: {0}", ex.StackTrace); + if(ex.InnerException != null) Debug.LogMessage(LogEventLevel.Error, "Exception Inner: {0}", ex.InnerException); context.Response.StatusCode = 400; context.Response.StatusDescription = "Bad Request"; diff --git a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs index 250b29d5..e9eeb5b5 100644 --- a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs +++ b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs @@ -9,6 +9,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -109,7 +110,7 @@ namespace PepperDash.Essentials.Devices.Common public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device"); var zone = dc.Properties.Value("zone"); return new GenericAudioOutWithVolume(dc.Key, dc.Name, dc.Properties.Value("volumeDeviceKey"), zone); diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs index 84880654..502902b9 100644 --- a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs @@ -8,6 +8,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Devices.Common.Codec; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.AudioCodec { @@ -25,7 +26,7 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec { if (!IsInCall) { - Debug.Console(1, this, "Dial: {0}", number); + Debug.LogMessage(LogEventLevel.Debug, this, "Dial: {0}", number); var call = new CodecActiveCallItem() { Name = "Mock Outgoing Call", @@ -42,20 +43,20 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec } else { - Debug.Console(1, this, "Already in call. Cannot dial new call."); + Debug.LogMessage(LogEventLevel.Debug, this, "Already in call. Cannot dial new call."); } } public override void EndCall(CodecActiveCallItem call) { - Debug.Console(1, this, "EndCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "EndCall"); ActiveCalls.Remove(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call); } public override void EndAllCalls() { - Debug.Console(1, this, "EndAllCalls"); + Debug.LogMessage(LogEventLevel.Debug, this, "EndAllCalls"); for (int i = ActiveCalls.Count - 1; i >= 0; i--) { var call = ActiveCalls[i]; @@ -66,20 +67,20 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec public override void AcceptCall(CodecActiveCallItem call) { - Debug.Console(1, this, "AcceptCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "AcceptCall"); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call); } public override void RejectCall(CodecActiveCallItem call) { - Debug.Console(1, this, "RejectCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "RejectCall"); ActiveCalls.Remove(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call); } public override void SendDtmf(string s) { - Debug.Console(1, this, "BEEP BOOP SendDTMF: {0}", s); + Debug.LogMessage(LogEventLevel.Debug, this, "BEEP BOOP SendDTMF: {0}", s); } /// @@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec /// public void TestIncomingAudioCall(string number) { - Debug.Console(1, this, "TestIncomingAudioCall from {0}", number); + Debug.LogMessage(LogEventLevel.Debug, this, "TestIncomingAudioCall from {0}", number); var call = new CodecActiveCallItem() { Name = number, Id = number, Number = number, Type = eCodecCallType.Audio, Direction = eCodecCallDirection.Incoming }; ActiveCalls.Add(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call); @@ -122,7 +123,7 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new MockAc Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new MockAc Device"); var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); return new AudioCodec.MockAC(dc.Key, dc.Name, props); } diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs index bc7d371d..d606249f 100644 --- a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs @@ -17,6 +17,7 @@ using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Devices.Common.Codec; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Cameras { @@ -101,7 +102,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); @@ -111,8 +112,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras joinMap.SetCustomJoinData(customJoins); } - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); var commMonitor = cameraDevice as ICommunicationMonitor; commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig( diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs index 59c0d418..302aa0f1 100644 --- a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs @@ -15,6 +15,7 @@ using System.Text.RegularExpressions; using Crestron.SimplSharp.Reflection; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Cameras { @@ -161,7 +162,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras Communication.Connect(); - CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; + CommunicationMonitor.StatusChange += (o, a) => { Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; CommunicationMonitor.Start(); @@ -176,7 +177,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { - Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString()); if (e.Client.IsConnected) { @@ -193,7 +194,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras { if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1 - Debug.Console(2, this, "Sending:{0}", ComTextHelper.GetEscapedText(b)); + Debug.LogMessage(LogEventLevel.Verbose, this, "Sending:{0}", ComTextHelper.GetEscapedText(b)); Communication.SendBytes(b); } @@ -209,7 +210,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras IncomingBuffer.CopyTo(newBytes, 0); e.Bytes.CopyTo(newBytes, IncomingBuffer.Length); if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1 - Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes)); + Debug.LogMessage(LogEventLevel.Verbose, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes)); byte[] message = new byte[] { }; @@ -238,7 +239,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras case 0x40: { // ACK received - Debug.Console(2, this, "ACK Received"); + Debug.LogMessage(LogEventLevel.Verbose, this, "ACK Received"); break; } case 0x50: @@ -247,7 +248,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras if (message[2] == 0xFF) { // Completion received - Debug.Console(2, this, "Completion Received"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Completion Received"); } else { @@ -260,7 +261,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } else { - Debug.Console(2, this, "Response Queue is empty. Nothing to dequeue."); + Debug.LogMessage(LogEventLevel.Verbose, this, "Response Queue is empty. Nothing to dequeue."); } } @@ -275,37 +276,37 @@ namespace PepperDash.Essentials.Devices.Common.Cameras case 0x01: { // Message Length Error - Debug.Console(2, this, "Error from device: Message Length Error"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: Message Length Error"); break; } case 0x02: { // Syntax Error - Debug.Console(2, this, "Error from device: Syntax Error"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: Syntax Error"); break; } case 0x03: { // Command Buffer Full - Debug.Console(2, this, "Error from device: Command Buffer Full"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: Command Buffer Full"); break; } case 0x04: { // Command Cancelled - Debug.Console(2, this, "Error from device: Command Cancelled"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: Command Cancelled"); break; } case 0x05: { // No Socket - Debug.Console(2, this, "Error from device: No Socket"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: No Socket"); break; } case 0x41: { // Command not executable - Debug.Console(2, this, "Error from device: Command not executable"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error from device: Command not executable"); break; } } @@ -327,7 +328,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } catch (Exception err) { - Debug.Console(2, this, "Error parsing feedback: {0}", err); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error parsing feedback: {0}", err); } finally { @@ -645,7 +646,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new CameraVisca Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new CameraVisca Device"); var comm = CommFactory.CreateCommForDevice(dc); var props = Newtonsoft.Json.JsonConvert.DeserializeObject( dc.Properties.ToString()); diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs index 42ef5b76..6d8d4a4a 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using Newtonsoft.Json; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Codec { @@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting) { - Debug.Console(2, "*****************OnMeetingChange. id: {0} changeType: {1}**********************", meeting.Id, changeType); + Debug.LogMessage(LogEventLevel.Verbose, "*****************OnMeetingChange. id: {0} changeType: {1}**********************", meeting.Id, changeType); if (changeType != (changeType & meeting.NotifiedChangeTypes)) { // Add this change type to the NotifiedChangeTypes @@ -107,7 +108,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec } else { - Debug.Console(2, "Meeting: {0} already notified of changeType: {1}", meeting.Id, changeType); + Debug.LogMessage(LogEventLevel.Verbose, "Meeting: {0} already notified of changeType: {1}", meeting.Id, changeType); } } @@ -127,22 +128,22 @@ namespace PepperDash.Essentials.Devices.Common.Codec if (eMeetingEventChangeType.MeetingStartWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStartWarning) && m.TimeToMeetingStart.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingStart.Seconds > 0) // Meeting is about to start { - Debug.Console(2, "********************* MeetingStartWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingStart.TotalMinutes, m.TimeToMeetingStart.Seconds); + Debug.LogMessage(LogEventLevel.Verbose, "********************* MeetingStartWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingStart.TotalMinutes, m.TimeToMeetingStart.Seconds); changeType = eMeetingEventChangeType.MeetingStartWarning; } else if (eMeetingEventChangeType.MeetingStart != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStart) && Math.Abs(m.TimeToMeetingStart.TotalMinutes) < meetingTimeEpsilon) // Meeting Start { - Debug.Console(2, "********************* MeetingStart"); + Debug.LogMessage(LogEventLevel.Verbose, "********************* MeetingStart"); changeType = eMeetingEventChangeType.MeetingStart; } else if (eMeetingEventChangeType.MeetingEndWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEndWarning) && m.TimeToMeetingEnd.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingEnd.Seconds > 0) // Meeting is about to end { - Debug.Console(2, "********************* MeetingEndWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingEnd.TotalMinutes, m.TimeToMeetingEnd.Seconds); + Debug.LogMessage(LogEventLevel.Verbose, "********************* MeetingEndWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingEnd.TotalMinutes, m.TimeToMeetingEnd.Seconds); changeType = eMeetingEventChangeType.MeetingEndWarning; } else if (eMeetingEventChangeType.MeetingEnd != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEnd) && Math.Abs(m.TimeToMeetingEnd.TotalMinutes) < meetingTimeEpsilon) // Meeting has ended { - Debug.Console(2, "********************* MeetingEnd"); + Debug.LogMessage(LogEventLevel.Verbose, "********************* MeetingEnd"); changeType = eMeetingEventChangeType.MeetingEnd; } @@ -214,7 +215,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec { var joinable = StartTime.AddMinutes(-MinutesBeforeMeeting) <= DateTime.Now && DateTime.Now <= EndTime.AddSeconds(-_joinableCooldownSeconds); - //Debug.Console(2, "Meeting Id: {0} joinable: {1}", Id, joinable); + //Debug.LogMessage(LogEventLevel.Verbose, "Meeting Id: {0} joinable: {1}", Id, joinable); return joinable; } } diff --git a/src/PepperDash.Essentials.Devices.Common/DeviceFactory.cs b/src/PepperDash.Essentials.Devices.Common/DeviceFactory.cs index 00678803..bd8cf92f 100644 --- a/src/PepperDash.Essentials.Devices.Common/DeviceFactory.cs +++ b/src/PepperDash.Essentials.Devices.Common/DeviceFactory.cs @@ -5,6 +5,7 @@ using System.Linq; using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -29,7 +30,7 @@ namespace PepperDash.Essentials.Devices.Common } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + Debug.LogMessage(LogEventLevel.Information, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); } } } diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/BasicIrDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Displays/BasicIrDisplay.cs index 59e67278..654b2fcf 100644 --- a/src/PepperDash.Essentials.Devices.Common/Displays/BasicIrDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Displays/BasicIrDisplay.cs @@ -8,6 +8,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Displays { @@ -39,8 +40,8 @@ namespace PepperDash.Essentials.Devices.Common.Displays IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath); DeviceManager.AddDevice(IrPort); - IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp); - IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown); + IsWarmingUpFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Warming up={0}", _IsWarmingUp); + IsCoolingDownFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Cooling down={0}", _IsCoolingDown); InputPorts.AddRange(new RoutingPortCollection { @@ -166,7 +167,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays /// A delegate containing the input selector method to call public override void ExecuteSwitch(object inputSelector) { - Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); + Debug.LogMessage(LogEventLevel.Verbose, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); Action finishSwitch = () => { @@ -208,7 +209,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BasicIrDisplay Device"); var ir = IRPortHelper.GetIrPort(dc.Properties); if (ir != null) { diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs b/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs index 17edfad0..1d2d3589 100644 --- a/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs @@ -9,6 +9,7 @@ using PepperDash.Essentials.Core.Bridges; using Feedback = PepperDash.Essentials.Core.Feedback; using Newtonsoft.Json; using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Displays { @@ -114,7 +115,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays } else { - Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } LinkDisplayToApi(displayDevice, trilist, joinMap); @@ -122,8 +123,8 @@ namespace PepperDash.Essentials.Devices.Common.Displays protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap) { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, "Linking to Display: {0}", displayDevice.Name); trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; @@ -145,7 +146,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); - twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); + twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Information, "CurrentInputFeedback_OutputChange {0}", a.StringValue); inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); @@ -199,16 +200,16 @@ namespace PepperDash.Essentials.Devices.Common.Displays var tempKey = inputKeys.ElementAt(i); trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", + Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString()); trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); } else - Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", + Debug.LogMessage(LogEventLevel.Information, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); } - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => { if (a == 0) diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs index a183b1d6..dd036205 100644 --- a/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs @@ -8,6 +8,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.DeviceTypeInterfaces; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Displays { @@ -25,7 +26,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { return () => { - Debug.Console(2, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off"); return _PowerIsOn; }; } } @@ -35,7 +36,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { return () => { - Debug.Console(2, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down"); return _IsCoolingDown; }; } @@ -46,7 +47,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { return () => { - Debug.Console(2, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); + Debug.LogMessage(LogEventLevel.Verbose, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up"); return _IsWarmingUp; }; } @@ -122,7 +123,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays // Fake cool-down cycle CooldownTimer = new CTimer(o => { - Debug.Console(2, this, "Cooldown timer ending"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Cooldown timer ending"); _IsCoolingDown = false; IsCoolingDownFeedback.InvokeFireUpdate(); _PowerIsOn = false; @@ -141,7 +142,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays public override void ExecuteSwitch(object selector) { - Debug.Console(2, this, "ExecuteSwitch: {0}", selector); + Debug.LogMessage(LogEventLevel.Verbose, this, "ExecuteSwitch: {0}", selector); if (!_PowerIsOn) { @@ -167,7 +168,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays if (currentInput != null) { - Debug.Console(2, this, "SetInput: {0}", selector); + Debug.LogMessage(LogEventLevel.Verbose, this, "SetInput: {0}", selector); currentInput.IsSelected = false; } @@ -214,7 +215,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { //while (pressRelease) //{ - Debug.Console(2, this, "Volume Down {0}", pressRelease); + Debug.LogMessage(LogEventLevel.Verbose, this, "Volume Down {0}", pressRelease); if (pressRelease) { var newLevel = _FakeVolumeLevel + VolumeInterval; @@ -228,7 +229,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays { //while (pressRelease) //{ - Debug.Console(2, this, "Volume Up {0}", pressRelease); + Debug.LogMessage(LogEventLevel.Verbose, this, "Volume Up {0}", pressRelease); if (pressRelease) { var newLevel = _FakeVolumeLevel - VolumeInterval; diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs index 50a65272..940a519e 100644 --- a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs @@ -2,6 +2,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; @@ -55,7 +56,7 @@ namespace PepperDash.Essentials.Devices.Common.Generic public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Source Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Source Device"); return new GenericSource(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs index f3aa2df4..f4062c98 100644 --- a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs @@ -10,6 +10,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Devices.Common public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Source Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Source Device"); return new GenericSource(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Devices.Common/Lighting/LightingBase.cs b/src/PepperDash.Essentials.Devices.Common/Lighting/LightingBase.cs index 12b027b3..1c67d426 100644 --- a/src/PepperDash.Essentials.Devices.Common/Lighting/LightingBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/Lighting/LightingBase.cs @@ -12,6 +12,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Lighting; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Lighting { @@ -43,7 +44,7 @@ namespace PepperDash.Essentials.Devices.Common.Lighting public void SimulateSceneSelect(string sceneName) { - Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName); + Debug.LogMessage(LogEventLevel.Debug, this, "Simulating selection of scene '{0}'", sceneName); var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName)); @@ -91,7 +92,7 @@ namespace PepperDash.Essentials.Devices.Common.Lighting } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } return LinkLightingToApi(lightingDevice, trilist, joinMap); @@ -99,9 +100,9 @@ namespace PepperDash.Essentials.Devices.Common.Lighting protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap) { - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); + Debug.LogMessage(LogEventLevel.Information, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); // GenericLighitng Actions & FeedBack trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); diff --git a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj index 816ebab7..c7feb653 100644 --- a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj +++ b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj @@ -27,6 +27,6 @@ - + \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs index 8cc29f0f..1728939d 100644 --- a/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs @@ -15,6 +15,7 @@ using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -386,11 +387,11 @@ namespace PepperDash.Essentials.Devices.Common } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to SetTopBox: {0}", Name); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, "Linking to SetTopBox: {0}", Name); trilist.OnlineStatusChange += new OnlineStatusChangeEventHandler((o, a) => { @@ -504,7 +505,7 @@ namespace PepperDash.Essentials.Devices.Common public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new SetTopBox Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new SetTopBox Device"); var irCont = IRPortHelper.GetIrOutputPortController(dc); var config = dc.Properties.ToObject(); var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config); diff --git a/src/PepperDash.Essentials.Devices.Common/Shades/RelayControlledShade.cs b/src/PepperDash.Essentials.Devices.Common/Shades/RelayControlledShade.cs index a8fc5fd4..085517b2 100644 --- a/src/PepperDash.Essentials.Devices.Common/Shades/RelayControlledShade.cs +++ b/src/PepperDash.Essentials.Devices.Common/Shades/RelayControlledShade.cs @@ -5,6 +5,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.CrestronIO; using PepperDash.Essentials.Core.Shades; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Shades { @@ -47,21 +48,21 @@ namespace PepperDash.Essentials.Devices.Common.Shades public override void Open() { - Debug.Console(1, this, "Opening Shade: '{0}'", this.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Opening Shade: '{0}'", this.Name); PulseOutput(OpenRelay, RelayPulseTime); } public override void Stop() { - Debug.Console(1, this, "Stopping Shade: '{0}'", this.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Shade: '{0}'", this.Name); PulseOutput(StopOrPresetRelay, RelayPulseTime); } public override void Close() { - Debug.Console(1, this, "Closing Shade: '{0}'", this.Name); + Debug.LogMessage(LogEventLevel.Debug, this, "Closing Shade: '{0}'", this.Name); PulseOutput(CloseRelay, RelayPulseTime); } @@ -87,7 +88,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades } else { - Debug.Console(1, this, "Error: Unable to get relay on port '{0}' from device with key '{1}'", relayConfig.PortNumber, relayConfig.PortDeviceKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Error: Unable to get relay on port '{0}' from device with key '{1}'", relayConfig.PortNumber, relayConfig.PortDeviceKey); return null; } } @@ -117,7 +118,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device"); var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); return new RelayControlledShade(dc.Key, dc.Name, props); diff --git a/src/PepperDash.Essentials.Devices.Common/Shades/ShadeController.cs b/src/PepperDash.Essentials.Devices.Common/Shades/ShadeController.cs index a229cb6d..43ce0abc 100644 --- a/src/PepperDash.Essentials.Devices.Common/Shades/ShadeController.cs +++ b/src/PepperDash.Essentials.Devices.Common/Shades/ShadeController.cs @@ -3,6 +3,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Shades; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Shades { @@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Devices.Common.Shades public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new ShadeController Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new ShadeController Device"); var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); return new ShadeController(dc.Key, dc.Name, props); diff --git a/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs index 67b205e5..4dcb663a 100644 --- a/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs +++ b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs @@ -7,6 +7,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Devices.Common.Sources; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.SoftCodec @@ -40,19 +41,19 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec { CrestronInvoke.BeginInvoke(o => { - Debug.Console(1, this, "Run route action '{0}' on SourceList: {1}", routeKey, sourceListKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Run route action '{0}' on SourceList: {1}", routeKey, sourceListKey); var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey); if (dict == null) { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey); + Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Config source list '{0}' not found", sourceListKey); return; } // Try to get the list item by it's string key if (!dict.ContainsKey(routeKey)) { - Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", + Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: No item '{0}' found on config list '{1}'", routeKey, sourceListKey); return; } @@ -97,7 +98,7 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec if (dest == null) { - Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); return false; } @@ -112,7 +113,7 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; if (source == null) { - Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); + Debug.LogMessage(LogEventLevel.Debug, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); return false; } dest.ReleaseAndMakeRoute(source, route.Type); @@ -169,7 +170,7 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new BlueJeansPc Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BlueJeansPc Device"); return new SoftCodec.BlueJeansPc(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Devices.Common/SoftCodec/GenericSoftCodec.cs b/src/PepperDash.Essentials.Devices.Common/SoftCodec/GenericSoftCodec.cs index f6661256..4c45a929 100644 --- a/src/PepperDash.Essentials.Devices.Common/SoftCodec/GenericSoftCodec.cs +++ b/src/PepperDash.Essentials.Devices.Common/SoftCodec/GenericSoftCodec.cs @@ -2,6 +2,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; +using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; @@ -73,7 +74,7 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Attempting to create new Generic SoftCodec Device"); + Debug.LogMessage(LogEventLevel.Debug, "Attempting to create new Generic SoftCodec Device"); var props = dc.Properties.ToObject(); diff --git a/src/PepperDash.Essentials.Devices.Common/Sources/InRoomPc.cs b/src/PepperDash.Essentials.Devices.Common/Sources/InRoomPc.cs index af5f274f..565956f4 100644 --- a/src/PepperDash.Essentials.Devices.Common/Sources/InRoomPc.cs +++ b/src/PepperDash.Essentials.Devices.Common/Sources/InRoomPc.cs @@ -4,6 +4,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Sources { @@ -68,7 +69,7 @@ namespace PepperDash.Essentials.Devices.Common.Sources public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new InRoomPc Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new InRoomPc Device"); return new InRoomPc(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Devices.Common/Sources/Laptop.cs b/src/PepperDash.Essentials.Devices.Common/Sources/Laptop.cs index dd1f38c2..7aac6267 100644 --- a/src/PepperDash.Essentials.Devices.Common/Sources/Laptop.cs +++ b/src/PepperDash.Essentials.Devices.Common/Sources/Laptop.cs @@ -4,6 +4,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Sources { @@ -68,7 +69,7 @@ namespace PepperDash.Essentials.Devices.Common.Sources public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Laptop Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Laptop Device"); return new Laptop(dc.Key, dc.Name); } } diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs index addc0211..5c8f9163 100644 --- a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs @@ -14,6 +14,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Devices.Common foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType()) { - Debug.Console(2, this, "Expected IR Function Name: {0}", value); + Debug.LogMessage(LogEventLevel.Verbose, this, "Expected IR Function Name: {0}", value); } } @@ -173,11 +174,11 @@ namespace PepperDash.Essentials.Devices.Common } else { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); + Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Information, "Linking to Bridge Type {0}", GetType().Name); trilist.SetBoolSigAction(joinMap.UpArrow.JoinNumber, Up); trilist.SetBoolSigAction(joinMap.DnArrow.JoinNumber, Down); @@ -198,7 +199,7 @@ namespace PepperDash.Essentials.Devices.Common public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new AppleTV Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new AppleTV Device"); var irCont = IRPortHelper.GetIrOutputPortController(dc); return new AppleTV(dc.Key, dc.Name, irCont); } diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs index 4e053b78..4364610b 100644 --- a/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs @@ -10,6 +10,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common { @@ -157,7 +158,7 @@ namespace PepperDash.Essentials.Devices.Common public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new Roku Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Roku Device"); var irCont = IRPortHelper.GetIrOutputPortController(dc); return new Roku2(dc.Key, dc.Name, irCont); diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs index 87f0fe55..23023857 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs @@ -16,6 +16,7 @@ using PepperDash.Essentials.Devices.Common.Cameras; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.VideoCodec { @@ -50,10 +51,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec DirectoryBrowseHistory = new List(); // Debug helpers - MuteFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Mute={0}", _IsMuted); - PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Privacy={0}", _PrivacyModeIsOn); - SharingSourceFeedback.OutputChange += (o, a) => Debug.Console(1, this, "SharingSource={0}", _SharingSource); - VolumeLevelFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Volume={0}", _VolumeLevel); + MuteFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Debug, this, "Mute={0}", _IsMuted); + PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Debug, this, "Privacy={0}", _PrivacyModeIsOn); + SharingSourceFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Debug, this, "SharingSource={0}", _SharingSource); + VolumeLevelFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Debug, this, "Volume={0}", _VolumeLevel); CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => DirectoryBrowseHistory.Count > 0); @@ -140,7 +141,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void Dial(string number) { - Debug.Console(1, this, "Dial: {0}", number); + Debug.LogMessage(LogEventLevel.Debug, this, "Dial: {0}", number); var call = new CodecActiveCallItem() { Name = number, Number = number, Id = number, Status = eCodecCallStatus.Dialing, Direction = eCodecCallDirection.Outgoing, Type = eCodecCallType.Video }; ActiveCalls.Add(call); OnCallStatusChange(call); @@ -156,7 +157,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public override void Dial(Meeting meeting) { - Debug.Console(1, this, "Dial Meeting: {0}", meeting.Id); + Debug.LogMessage(LogEventLevel.Debug, this, "Dial Meeting: {0}", meeting.Id); var call = new CodecActiveCallItem() { Name = meeting.Title, Number = meeting.Id, Id = meeting.Id, Status = eCodecCallStatus.Dialing, Direction = eCodecCallDirection.Outgoing, Type = eCodecCallType.Video }; ActiveCalls.Add(call); OnCallStatusChange(call); @@ -177,7 +178,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void EndCall(CodecActiveCallItem call) { - Debug.Console(1, this, "EndCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "EndCall"); ActiveCalls.Remove(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call); //ActiveCallCountFeedback.FireUpdate(); @@ -188,7 +189,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void EndAllCalls() { - Debug.Console(1, this, "EndAllCalls"); + Debug.LogMessage(LogEventLevel.Debug, this, "EndAllCalls"); for(int i = ActiveCalls.Count - 1; i >= 0; i--) { var call = ActiveCalls[i]; @@ -203,7 +204,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void AcceptCall(CodecActiveCallItem call) { - Debug.Console(1, this, "AcceptCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "AcceptCall"); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call); new CTimer(o => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000); // should already be in active list @@ -214,7 +215,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void RejectCall(CodecActiveCallItem call) { - Debug.Console(1, this, "RejectCall"); + Debug.LogMessage(LogEventLevel.Debug, this, "RejectCall"); ActiveCalls.Remove(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call); //ActiveCallCountFeedback.FireUpdate(); @@ -226,7 +227,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void SendDtmf(string s) { - Debug.Console(1, this, "SendDTMF: {0}", s); + Debug.LogMessage(LogEventLevel.Debug, this, "SendDTMF: {0}", s); } /// @@ -268,7 +269,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void ExecuteSwitch(object selector) { - Debug.Console(1, this, "ExecuteSwitch: {0}", selector); + Debug.LogMessage(LogEventLevel.Debug, this, "ExecuteSwitch: {0}", selector); _SharingSource = selector.ToString(); } @@ -330,7 +331,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void PrivacyModeOn() { - Debug.Console(1, this, "PrivacyMuteOn"); + Debug.LogMessage(LogEventLevel.Debug, this, "PrivacyMuteOn"); if (_PrivacyModeIsOn) return; _PrivacyModeIsOn = true; @@ -342,7 +343,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public override void PrivacyModeOff() { - Debug.Console(1, this, "PrivacyMuteOff"); + Debug.LogMessage(LogEventLevel.Debug, this, "PrivacyMuteOff"); if (!_PrivacyModeIsOn) return; _PrivacyModeIsOn = false; @@ -355,7 +356,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public override void PrivacyModeToggle() { _PrivacyModeIsOn = !_PrivacyModeIsOn; - Debug.Console(1, this, "PrivacyMuteToggle: {0}", _PrivacyModeIsOn); + Debug.LogMessage(LogEventLevel.Debug, this, "PrivacyMuteToggle: {0}", _PrivacyModeIsOn); PrivacyModeIsOnFeedback.FireUpdate(); } @@ -368,7 +369,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public void TestIncomingVideoCall(string url) { - Debug.Console(1, this, "TestIncomingVideoCall from {0}", url); + Debug.LogMessage(LogEventLevel.Debug, this, "TestIncomingVideoCall from {0}", url); var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type= eCodecCallType.Video, Direction = eCodecCallDirection.Incoming }; ActiveCalls.Add(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call); @@ -383,7 +384,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public void TestIncomingAudioCall(string url) { - Debug.Console(1, this, "TestIncomingAudioCall from {0}", url); + Debug.LogMessage(LogEventLevel.Debug, this, "TestIncomingAudioCall from {0}", url); var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type = eCodecCallType.Audio, Direction = eCodecCallDirection.Incoming }; ActiveCalls.Add(call); SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Ringing, call); @@ -396,7 +397,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public void TestFarEndHangup() { - Debug.Console(1, this, "TestFarEndHangup"); + Debug.LogMessage(LogEventLevel.Debug, this, "TestFarEndHangup"); } @@ -676,11 +677,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec var camera = Cameras.FirstOrDefault(c => c.Key.ToLower().IndexOf(key.ToLower()) > -1); if (camera != null) { - Debug.Console(2, this, "Selected Camera with key: '{0}'", camera.Key); + Debug.LogMessage(LogEventLevel.Verbose, this, "Selected Camera with key: '{0}'", camera.Key); SelectedCamera = camera; } else - Debug.Console(2, this, "Unable to select camera with key: '{0}'", key); + Debug.LogMessage(LogEventLevel.Verbose, this, "Unable to select camera with key: '{0}'", key); } #endregion @@ -736,11 +737,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { if (SelectedCamera is IAmFarEndCamera) { - Debug.Console(1, this, "Selecting Far End Preset: {0}", preset); + Debug.LogMessage(LogEventLevel.Debug, this, "Selecting Far End Preset: {0}", preset); } else { - Debug.Console(1, this, "Selecting Near End Preset: {0}", preset); + Debug.LogMessage(LogEventLevel.Debug, this, "Selecting Near End Preset: {0}", preset); } } @@ -768,7 +769,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public void SelectFarEndPreset(int i) { - Debug.Console(1, this, "Selecting Far End Preset: {0}", i); + Debug.LogMessage(LogEventLevel.Debug, this, "Selecting Far End Preset: {0}", i); } #endregion @@ -841,7 +842,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new MockVC Device"); + Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new MockVC Device"); return new VideoCodec.MockVC(dc); } } diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs index 0c008849..3b4d5ab9 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.VideoCodec; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.Cameras { @@ -27,7 +28,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void PositionHome() { - Debug.Console(1, this, "Resetting to home position"); + Debug.LogMessage(LogEventLevel.Debug, this, "Resetting to home position"); } #endregion @@ -36,17 +37,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void PanLeft() { - Debug.Console(1, this, "Panning Left"); + Debug.LogMessage(LogEventLevel.Debug, this, "Panning Left"); } public void PanRight() { - Debug.Console(1, this, "Panning Right"); + Debug.LogMessage(LogEventLevel.Debug, this, "Panning Right"); } public void PanStop() { - Debug.Console(1, this, "Stopping Pan"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Pan"); } #endregion @@ -55,17 +56,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void TiltDown() { - Debug.Console(1, this, "Tilting Down"); + Debug.LogMessage(LogEventLevel.Debug, this, "Tilting Down"); } public void TiltUp() { - Debug.Console(1, this, "Tilting Up"); + Debug.LogMessage(LogEventLevel.Debug, this, "Tilting Up"); } public void TiltStop() { - Debug.Console(1, this, "Stopping Tilt"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Tilt"); } #endregion @@ -74,17 +75,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void ZoomIn() { - Debug.Console(1, this, "Zooming In"); + Debug.LogMessage(LogEventLevel.Debug, this, "Zooming In"); } public void ZoomOut() { - Debug.Console(1, this, "Zooming Out"); + Debug.LogMessage(LogEventLevel.Debug, this, "Zooming Out"); } public void ZoomStop() { - Debug.Console(1, this, "Stopping Zoom"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Zoom"); } #endregion @@ -93,22 +94,22 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void FocusNear() { - Debug.Console(1, this, "Focusing Near"); + Debug.LogMessage(LogEventLevel.Debug, this, "Focusing Near"); } public void FocusFar() { - Debug.Console(1, this, "Focusing Far"); + Debug.LogMessage(LogEventLevel.Debug, this, "Focusing Far"); } public void FocusStop() { - Debug.Console(1, this, "Stopping Focus"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Focus"); } public void TriggerAutoFocus() { - Debug.Console(1, this, "AutoFocus Triggered"); + Debug.LogMessage(LogEventLevel.Debug, this, "AutoFocus Triggered"); } #endregion @@ -136,7 +137,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void PositionHome() { - Debug.Console(1, this, "Resetting to home position"); + Debug.LogMessage(LogEventLevel.Debug, this, "Resetting to home position"); } #endregion @@ -145,17 +146,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void PanLeft() { - Debug.Console(1, this, "Panning Left"); + Debug.LogMessage(LogEventLevel.Debug, this, "Panning Left"); } public void PanRight() { - Debug.Console(1, this, "Panning Right"); + Debug.LogMessage(LogEventLevel.Debug, this, "Panning Right"); } public void PanStop() { - Debug.Console(1, this, "Stopping Pan"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Pan"); } #endregion @@ -164,17 +165,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void TiltDown() { - Debug.Console(1, this, "Tilting Down"); + Debug.LogMessage(LogEventLevel.Debug, this, "Tilting Down"); } public void TiltUp() { - Debug.Console(1, this, "Tilting Up"); + Debug.LogMessage(LogEventLevel.Debug, this, "Tilting Up"); } public void TiltStop() { - Debug.Console(1, this, "Stopping Tilt"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Tilt"); } #endregion @@ -183,17 +184,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public void ZoomIn() { - Debug.Console(1, this, "Zooming In"); + Debug.LogMessage(LogEventLevel.Debug, this, "Zooming In"); } public void ZoomOut() { - Debug.Console(1, this, "Zooming Out"); + Debug.LogMessage(LogEventLevel.Debug, this, "Zooming Out"); } public void ZoomStop() { - Debug.Console(1, this, "Stopping Zoom"); + Debug.LogMessage(LogEventLevel.Debug, this, "Stopping Zoom"); } #endregion diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs index 1e83ad32..b4b2efad 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs @@ -20,6 +20,7 @@ using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; using PepperDash.Essentials.Core.Bridges.JoinMaps; using Feedback = PepperDash.Essentials.Core.Feedback; +using Serilog.Events; namespace PepperDash.Essentials.Devices.Common.VideoCodec { @@ -259,7 +260,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } catch (Exception e) { - Debug.Console(2, this, "Error in SetIsReady() : {0}", e); + Debug.LogMessage(LogEventLevel.Verbose, this, "Error in SetIsReady() : {0}", e); } }); } @@ -270,14 +271,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public virtual void ListCalls() { - Debug.Console(1, this, "Active Calls:"); + Debug.LogMessage(LogEventLevel.Debug, this, "Active Calls:"); var sb = new StringBuilder(); foreach (var c in ActiveCalls) { sb.AppendFormat("id: {0} number: {1} -- name: {2} status: {3} onHold: {4}\r\n", c.Id, c.Number, c.Name, c.Status, c.IsOnHold); } - Debug.Console(1, this, "\n{0}\n", sb.ToString()); + Debug.LogMessage(LogEventLevel.Debug, this, "\n{0}\n", sb.ToString()); } public abstract void StandbyActivate(); @@ -329,7 +330,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// protected void LinkVideoCodecToApi(VideoCodecBase codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) { - Debug.Console(1, this, "Linking to Trilist {0}", trilist.ID.ToString("X")); + Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist {0}", trilist.ID.ToString("X")); LinkVideoCodecDtmfToApi(trilist, joinMap); @@ -697,7 +698,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { if (meetingIndex >= maxParticipants * offset) break; - // Debug.Console(2, this, + // Debug.LogMessage(LogEventLevel.Verbose, this, //@"Updating Participant on xsig: //Name: {0} (s{9}) //AudioMute: {1} (d{10}) @@ -739,7 +740,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec tokenArray[digitalIndex + 5] = new XSigDigitalToken(digitalIndex + 6, participant.HandIsRaisedFb); tokenArray[digitalIndex + 6] = new XSigDigitalToken(digitalIndex + 7, participant.IsPinnedFb); - Debug.Console(2, this, "Index: {0} byte value: {1}", digitalIndex + 7, ComTextHelper.GetEscapedText(tokenArray[digitalIndex + 6].GetBytes())); + Debug.LogMessage(LogEventLevel.Verbose, this, "Index: {0} byte value: {1}", digitalIndex + 7, ComTextHelper.GetEscapedText(tokenArray[digitalIndex + 6].GetBytes())); //serials tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, participant.Name); @@ -778,7 +779,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec var returnString = GetXSigString(tokenArray); - //Debug.Console(2, this, "{0}", ComTextHelper.GetEscapedText(Encoding.GetEncoding(28591).GetBytes(returnString))); + //Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", ComTextHelper.GetEscapedText(Encoding.GetEncoding(28591).GetBytes(returnString))); return returnString; @@ -811,14 +812,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec for (uint i = 0; i < joinMap.DialMeetingStart.JoinSpan; i++) { - Debug.Console(1, this, "Setting action to Dial Meeting {0} to digital join {1}", i + 1, joinMap.DialMeetingStart.JoinNumber + i); + Debug.LogMessage(LogEventLevel.Debug, this, "Setting action to Dial Meeting {0} to digital join {1}", i + 1, joinMap.DialMeetingStart.JoinNumber + i); var joinNumber = joinMap.DialMeetingStart.JoinNumber + i; var mtg = i + 1; var index = (int)i; trilist.SetSigFalseAction(joinNumber, () => { - Debug.Console(1, this, "Meeting {0} Selected (EISC dig-o{1}) > _currentMeetings[{2}].Id: {3}, Title: {4}", + Debug.LogMessage(LogEventLevel.Debug, this, "Meeting {0} Selected (EISC dig-o{1}) > _currentMeetings[{2}].Id: {3}, Title: {4}", mtg, joinMap.DialMeetingStart.JoinNumber + i, index, _currentMeetings[index].Id, _currentMeetings[index].Title); if (_currentMeetings[index] != null) Dial(_currentMeetings[index]); @@ -931,7 +932,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (meetingIndex >= _meetingsToDisplay * offset) { - Debug.Console(2, this, "Max Meetings reached"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Max Meetings reached"); break; } @@ -955,7 +956,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec while (meetingIndex < _meetingsToDisplay * offset) { - Debug.Console(2, this, "Clearing unused data. Meeting Index: {0} MaxMeetings * Offset: {1}", + Debug.LogMessage(LogEventLevel.Verbose, this, "Clearing unused data. Meeting Index: {0} MaxMeetings * Offset: {1}", meetingIndex, _meetingsToDisplay * offset); //digitals @@ -1003,7 +1004,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { var contactsCount = codec.DirectoryRoot.CurrentDirectoryResults.Where(c => c.ParentFolderId.Equals("root")).ToList().Count; trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)contactsCount); - Debug.Console(2, this, ">>> contactsCount: {0}", contactsCount); + Debug.LogMessage(LogEventLevel.Verbose, this, ">>> contactsCount: {0}", contactsCount); var clearBytes = XSigHelpers.ClearOutputs(); @@ -1012,7 +1013,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec var directoryXSig = UpdateDirectoryXSig(codec.DirectoryRoot, codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); - Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); + Debug.LogMessage(LogEventLevel.Verbose, this, "Directory XSig Length: {0}", directoryXSig.Length); trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); } @@ -1025,7 +1026,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec : args.Directory.CurrentDirectoryResults.Count; trilist.SetUshort(joinMap.DirectoryRowCount.JoinNumber, (ushort)argsCount); - Debug.Console(2, this, ">>> argsCount: {0}", argsCount); + Debug.LogMessage(LogEventLevel.Verbose, this, ">>> argsCount: {0}", argsCount); var clearBytes = XSigHelpers.ClearOutputs(); @@ -1033,7 +1034,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec Encoding.GetEncoding(XSigEncoding).GetString(clearBytes, 0, clearBytes.Length)); var directoryXSig = UpdateDirectoryXSig(args.Directory, codec.CurrentDirectoryResultIsNotDirectoryRoot.BoolValue == false); - Debug.Console(2, this, "Directory XSig Length: {0}", directoryXSig.Length); + Debug.LogMessage(LogEventLevel.Verbose, this, "Directory XSig Length: {0}", directoryXSig.Length); trilist.SetString(joinMap.DirectoryEntries.JoinNumber, directoryXSig); }; @@ -1159,7 +1160,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec // Create a new token array and set the size to the number of methods times the total number of signals var tokenArray = new XSigToken[maxMethods * offset]; - Debug.Console(2, this, "Creating XSIG token array with size {0}", maxMethods * offset); + Debug.LogMessage(LogEventLevel.Verbose, this, "Creating XSIG token array with size {0}", maxMethods * offset); // TODO: Add code to generate XSig data foreach (var method in contact.ContactMethods) @@ -1196,7 +1197,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec ? xSigMaxIndex : directory.CurrentDirectoryResults.Count]; - Debug.Console(2, this, "IsRoot: {0}, Directory Count: {1}, TokenArray.Length: {2}", isRoot, directory.CurrentDirectoryResults.Count, tokenArray.Length); + Debug.LogMessage(LogEventLevel.Verbose, this, "IsRoot: {0}, Directory Count: {1}, TokenArray.Length: {2}", isRoot, directory.CurrentDirectoryResults.Count, tokenArray.Length); var contacts = directory.CurrentDirectoryResults.Count > xSigMaxIndex ? directory.CurrentDirectoryResults.Take(xSigMaxIndex) @@ -1212,7 +1213,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec var arrayIndex = counterIndex - 1; var entryIndex = counterIndex; - Debug.Console(2, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}", + Debug.LogMessage(LogEventLevel.Verbose, this, "Entry{2:0000} Name: {0}, Folder ID: {1}, Type: {3}, ParentFolderId: {4}", entry.Name, entry.FolderId, entryIndex, entry.GetType().GetCType().FullName, entry.ParentFolderId); if (entry is DirectoryFolder) @@ -1250,7 +1251,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (callIndex < 0 || callIndex >= ActiveCalls.Count) { - Debug.Console(2, this, "Cannot end call. No call found at index: {0}", callIndex); + Debug.LogMessage(LogEventLevel.Verbose, this, "Cannot end call. No call found at index: {0}", callIndex); return; } @@ -1261,7 +1262,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "[End Call] Unable to find call at index '{0}'", i); + Debug.LogMessage(LogEventLevel.Information, this, "[End Call] Unable to find call at index '{0}'", i); } }); } @@ -1272,8 +1273,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); - Debug.Console(1, this, "Call Direction: {0}", args.CallItem.Direction); - Debug.Console(1, this, "Call is incoming: {0}", args.CallItem.Direction == eCodecCallDirection.Incoming); + Debug.LogMessage(LogEventLevel.Debug, this, "Call Direction: {0}", args.CallItem.Direction); + Debug.LogMessage(LogEventLevel.Debug, this, "Call is incoming: {0}", args.CallItem.Direction == eCodecCallDirection.Incoming); trilist.SetBool(joinMap.IncomingCall.JoinNumber, args.CallItem.Direction == eCodecCallDirection.Incoming && args.CallItem.Status == eCodecCallStatus.Ringing); if (args.CallItem.Direction == eCodecCallDirection.Incoming) @@ -1311,7 +1312,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "[Join Call] Unable to find call at index '{0}'", i); + Debug.LogMessage(LogEventLevel.Information, this, "[Join Call] Unable to find call at index '{0}'", i); } }); } @@ -1343,7 +1344,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "[Hold Call] Unable to find call at index '{0}'", i); + Debug.LogMessage(LogEventLevel.Information, this, "[Hold Call] Unable to find call at index '{0}'", i); } }); @@ -1358,7 +1359,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "[Resume Call] Unable to find call at index '{0}'", i); + Debug.LogMessage(LogEventLevel.Information, this, "[Resume Call] Unable to find call at index '{0}'", i); } }); } @@ -1371,7 +1372,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (!args.DeviceOnLine) return; // TODO [ ] #983 - Debug.Console(0, this, "LinkVideoCodecCallControlsToApi: device is {0}, IsInCall {1}", args.DeviceOnLine ? "online" : "offline", IsInCall); + Debug.LogMessage(LogEventLevel.Information, this, "LinkVideoCodecCallControlsToApi: device is {0}, IsInCall {1}", args.DeviceOnLine ? "online" : "offline", IsInCall); trilist.SetBool(joinMap.HookState.JoinNumber, IsInCall); trilist.SetString(joinMap.CurrentCallData.JoinNumber, "\xFC"); trilist.SetString(joinMap.CurrentCallData.JoinNumber, UpdateCallStatusXSig()); @@ -1480,12 +1481,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "Warning: No call found at index {0} or call is not active.", callIndex); + Debug.LogMessage(LogEventLevel.Information, this, "Warning: No call found at index {0} or call is not active.", callIndex); } } else { - Debug.Console(0, this, "Warning: Invalid call index specified. Please use a value of 1-8."); + Debug.LogMessage(LogEventLevel.Information, this, "Warning: Invalid call index specified. Please use a value of 1-8."); } } } @@ -1684,7 +1685,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } else { - Debug.Console(0, this, "Unable to select. No camera found at index {0}", i); + Debug.LogMessage(LogEventLevel.Information, this, "Unable to select. No camera found at index {0}", i); } }); @@ -1787,7 +1788,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { if (u == 0 || u > codec.CallHistory.RecentCalls.Count) { - Debug.Console(2, this, "Recent Call History index out of range"); + Debug.LogMessage(LogEventLevel.Verbose, this, "Recent Call History index out of range"); return; } @@ -1974,7 +1975,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { PhonebookHasFolders = value; - Debug.Console(1, this, "Phonebook has folders: {0}", PhonebookHasFolders); + Debug.LogMessage(LogEventLevel.Debug, this, "Phonebook has folders: {0}", PhonebookHasFolders); } public void SetNumberOfContacts(int contacts) @@ -1982,7 +1983,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec NumberOfContacts = contacts; NumberOfContactsWasReceived = true; - Debug.Console(1, this, "Phonebook contains {0} contacts.", NumberOfContacts); + Debug.LogMessage(LogEventLevel.Debug, this, "Phonebook contains {0} contacts.", NumberOfContacts); CheckSyncStatus(); } @@ -2000,7 +2001,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) { InitialSyncComplete = true; - Debug.Console(1, this, "Initial Phonebook Sync Complete!"); + Debug.LogMessage(LogEventLevel.Debug, this, "Initial Phonebook Sync Complete!"); } else { diff --git a/src/PepperDash.Essentials/ControlSystem.cs b/src/PepperDash.Essentials/ControlSystem.cs index 74785d48..84bf12ec 100644 --- a/src/PepperDash.Essentials/ControlSystem.cs +++ b/src/PepperDash.Essentials/ControlSystem.cs @@ -11,10 +11,9 @@ using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.DeviceTypeInterfaces; using PepperDash.Essentials.Core.Web; -using PepperDash.Essentials.Devices.Common.Room; -using PepperDash.Essentials.Room.Config; using System; using System.Linq; +using Serilog.Events; namespace PepperDash.Essentials { @@ -69,7 +68,8 @@ namespace PepperDash.Essentials bool preventInitializationComplete = Global.ControlSystemIsDmpsType; if (preventInitializationComplete) { - Debug.Console(1, "******************* InitializeSystem() Entering **********************"); + Debug.LogMessage(LogEventLevel.Debug, "******************* InitializeSystem() Entering **********************"); + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); _initializeEvent = new CEvent(true, false); DeviceManager.AllDevicesRegistered += (o, a) => @@ -77,7 +77,8 @@ namespace PepperDash.Essentials _initializeEvent.Set(); }; _initializeEvent.Wait(30000); - Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); + Debug.LogMessage(LogEventLevel.Debug, "******************* InitializeSystem() Exiting **********************"); + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; } else @@ -105,7 +106,7 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(BridgeHelper.JoinmapMarkdown, "getjoinmapmarkdown" , "generate markdown of map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s), "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => Debug.LogMessage(LogEventLevel.Information, "CONSOLE MESSAGE: {0}", s), "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { @@ -161,7 +162,7 @@ namespace PepperDash.Essentials { try { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Determining Platform...."); + Debug.LogMessage(LogEventLevel.Information, "Determining Platform..."); string filePathPrefix; @@ -194,15 +195,17 @@ namespace PepperDash.Essentials { userFolder = "User"; nvramFolder = "Nvram"; - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, is4series ? "4-series" : "3-series"); + } + + Debug.LogMessage(LogEventLevel.Information, "Starting Essentials v{version:l} on {processorSeries:l} Appliance", Global.AssemblyVersion, is4series ? "4-series" : "3-series"); + //Debug.LogMessage(LogEventLevel.Information, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, is4series ? "4-series" : "3-series"); // Check if User/ProgramX exists if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + userFolder + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) { - Debug.Console(0, @"{0}/program{1} directory found", userFolder, InitialParametersClass.ApplicationNumber); + + Debug.LogMessage(LogEventLevel.Information, "{userFolder:l}/program{applicationNumber} directory found", userFolder, InitialParametersClass.ApplicationNumber); filePathPrefix = directoryPrefix + dirSeparator + userFolder + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } @@ -210,14 +213,16 @@ namespace PepperDash.Essentials else if (Directory.Exists(directoryPrefix + dirSeparator + nvramFolder + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) { - Debug.Console(0, @"{0}/program{1} directory found", nvramFolder, InitialParametersClass.ApplicationNumber); + Debug.LogMessage(LogEventLevel.Information, "{nvramFolder:l}/program{applicationNumber} directory found", nvramFolder, InitialParametersClass.ApplicationNumber); + filePathPrefix = directoryPrefix + dirSeparator + nvramFolder + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } // If neither exists, set path to User/ProgramX else { - Debug.Console(0, @"No previous directory found. Using {0}/program{1}", userFolder, InitialParametersClass.ApplicationNumber); + Debug.LogMessage(LogEventLevel.Information, "{userFolder:l}/program{applicationNumber} directory found", userFolder, InitialParametersClass.ApplicationNumber); + filePathPrefix = directoryPrefix + dirSeparator + userFolder + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } @@ -225,8 +230,7 @@ namespace PepperDash.Essentials else // Handles Linux OS (Virtual Control) { //Debug.SetDebugLevel(2); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.AssemblyVersion); + Debug.LogMessage(LogEventLevel.Information, "Starting Essentials v{version:l} on Virtual Control Server", Global.AssemblyVersion); // Set path to User/ filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator; @@ -236,7 +240,7 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(0, "Unable to Determine Platform due to Exception: {0}", e.Message); + Debug.LogMessage(LogEventLevel.Error, "Unable to determin platform due to exception: {exception}", e.Message); } } @@ -251,34 +255,33 @@ namespace PepperDash.Essentials PluginLoader.AddProgramAssemblies(); - new Core.DeviceFactory(); - new Devices.Common.DeviceFactory(); - new DeviceFactory(); + _ = new Core.DeviceFactory(); + _ = new Devices.Common.DeviceFactory(); + _ = new DeviceFactory(); - new Core.ProcessorExtensionDeviceFactory(); + _ = new ProcessorExtensionDeviceFactory(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration"); + Debug.LogMessage(LogEventLevel.Information, "Starting Essentials load from configuration"); var filesReady = SetupFilesystem(); if (filesReady) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Checking for plugins"); + Debug.LogMessage(LogEventLevel.Information, "Checking for plugins"); PluginLoader.LoadPlugins(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config..."); + Debug.LogMessage(LogEventLevel.Information, "Folder structure verified. Loading config..."); if (!ConfigReader.LoadConfig2()) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Essentials Load complete with errors"); + Debug.LogMessage(LogEventLevel.Information, "Essentials Load complete with errors"); return; } Load(); - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r\n" + - "-------------------------------------------------------------"); + Debug.LogMessage(LogEventLevel.Information, "Essentials load complete"); } else { - Debug.Console(0, + Debug.LogMessage(LogEventLevel.Information, @"---------------------------------------------- ------------------------------------------------ ------------------------------------------------ @@ -293,7 +296,7 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r\n{0}", e); + Debug.LogMessage(LogEventLevel.Information, "FATAL INITIALIZE ERROR. System is in an inconsistent state: {exception}", e); } finally { @@ -310,10 +313,10 @@ namespace PepperDash.Essentials /// bool SetupFilesystem() { - Debug.Console(0, "Verifying and/or creating folder structure"); + Debug.LogMessage(LogEventLevel.Information, "Verifying and/or creating folder structure"); var configDir = Global.FilePathPrefix; - Debug.Console(0, "FilePathPrefix: {0}", configDir); + Debug.LogMessage(LogEventLevel.Information, "FilePathPrefix: {filePathPrefix:l}", configDir); var configExists = Directory.Exists(configDir); if (!configExists) Directory.Create(configDir); @@ -342,7 +345,7 @@ namespace PepperDash.Essentials /// public void TearDown() { - Debug.Console(0, "Tearing down existing system"); + Debug.LogMessage(LogEventLevel.Information, "Tearing down existing system"); DeviceManager.DeactivateAll(); TieLineCollection.Default.Clear(); @@ -350,7 +353,7 @@ namespace PepperDash.Essentials foreach (var key in DeviceManager.GetDevices()) DeviceManager.RemoveDevice(key); - Debug.Console(0, "Tear down COMPLETE"); + Debug.LogMessage(LogEventLevel.Information, "Tear down COMPLETE"); } /// @@ -381,13 +384,13 @@ namespace PepperDash.Essentials { // Build the processor wrapper class - DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); + DeviceManager.AddDevice(new Core.Devices.CrestronProcessor("processor")); // Add global System Monitor device if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) { DeviceManager.AddDevice( - new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); + new Core.Monitoring.SystemMonitorController("systemMonitor")); } foreach (var devConf in ConfigReader.ConfigObject.Devices) @@ -396,7 +399,7 @@ namespace PepperDash.Essentials try { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type); + Debug.LogMessage(LogEventLevel.Information, "Creating device '{deviceKey:l}', type '{deviceType:l}'", devConf.Key, devConf.Type); // Skip this to prevent unnecessary warnings if (devConf.Key == "processor") { @@ -406,8 +409,8 @@ namespace PepperDash.Essentials String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase); if (!typeMatch) - Debug.Console(0, - "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", + Debug.LogMessage(LogEventLevel.Information, + "WARNING: Config file defines processor type as '{deviceType:l}' but actual processor is '{processorType:l}'! Some ports may not be available", devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); @@ -416,19 +419,19 @@ namespace PepperDash.Essentials if (newDev == null) - newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); + newDev = Core.DeviceFactory.GetDevice(devConf); if (newDev != null) DeviceManager.AddDevice(newDev); else - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); + Debug.LogMessage(LogEventLevel.Information, "ERROR: Cannot load unknown device type '{deviceType:l}', key '{deviceKey:l}'.", devConf.Type, devConf.Key); } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e); + Debug.LogMessage(LogEventLevel.Information, "ERROR: Creating device {deviceKey:l}. Skipping device. \r\n{exception}", devConf.Key, e); } } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); + Debug.LogMessage(LogEventLevel.Information, "All Devices Loaded."); } @@ -442,7 +445,7 @@ namespace PepperDash.Essentials // might be making their own internal sources/tie lines var tlc = TieLineCollection.Default; - //tlc.Clear(); + if (ConfigReader.ConfigObject.TieLines == null) { return; @@ -455,7 +458,7 @@ namespace PepperDash.Essentials tlc.Add(newTL); } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Tie Lines Loaded."); + Debug.LogMessage(LogEventLevel.Information, "All Tie Lines Loaded."); } @@ -466,7 +469,7 @@ namespace PepperDash.Essentials { if (ConfigReader.ConfigObject.Rooms == null) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration."); + Debug.LogMessage(LogEventLevel.Information, "Notice: Configuration contains no rooms - Is this intentional? This may be a valid configuration."); return; } @@ -479,57 +482,12 @@ namespace PepperDash.Essentials { continue; } - - // BuildMC(room as IEssentialsRoom); } - Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded."); + Debug.LogMessage(LogEventLevel.Information, "All Rooms Loaded."); } - /*private static void BuildMC(IEssentialsRoom room) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, $"Attempting to build Mobile Control Bridge for {room?.Key}"); - - CreateMobileControlBridge(room); - } - - private static void CreateMobileControlBridge(IEssentialsRoom room) - { - if(room == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, $"Room does not implement IEssentialsRoom"); - return; - } - - var mobileControl = GetMobileControlDevice(); - - mobileControl?.CreateMobileControlRoomBridge(room, mobileControl); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control Bridge Added..."); - } - - private static IMobileControl3 GetMobileControlDevice() - { - var mobileControlList = DeviceManager.AllDevices.OfType().ToList(); - - if (mobileControlList.Count > 1) - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, - "Multiple instances of Mobile Control Server found."); - - return null; - } - - if (mobileControlList.Count > 0) - { - return mobileControlList[0]; - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control not enabled for this system"); - return null; - }*/ - /// /// Fires up a logo server if not already running /// @@ -537,7 +495,7 @@ namespace PepperDash.Essentials { if (ConfigReader.ConfigObject.Rooms == null) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured. Bypassing Logo server startup."); + Debug.LogMessage(LogEventLevel.Information, "No rooms configured. Bypassing Logo server startup."); return; } @@ -545,7 +503,7 @@ namespace PepperDash.Essentials !ConfigReader.ConfigObject.Rooms.Any( CheckRoomConfig)) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "No rooms configured to use system Logo server. Bypassing Logo server startup"); + Debug.LogMessage(LogEventLevel.Information, "No rooms configured to use system Logo server. Bypassing Logo server startup"); return; } @@ -555,7 +513,7 @@ namespace PepperDash.Essentials } catch (Exception) { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program"); + Debug.LogMessage(LogEventLevel.Information, "NOTICE: Logo server cannot be started. Likely already running in another program"); } } @@ -587,7 +545,7 @@ namespace PepperDash.Essentials } catch { - Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config"); + Debug.LogMessage(LogEventLevel.Information, "Unable to find logo information in any room config"); return false; } } diff --git a/src/PepperDash.Essentials/Factory/DeviceFactory.cs b/src/PepperDash.Essentials/Factory/DeviceFactory.cs index 1f7cae95..73063e30 100644 --- a/src/PepperDash.Essentials/Factory/DeviceFactory.cs +++ b/src/PepperDash.Essentials/Factory/DeviceFactory.cs @@ -40,7 +40,7 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); + Debug.LogMessage(Serilog.Events.LogEventLevel.Error, "Unable to load type: '{exception}' DeviceFactory: {factoryName}", e, type.Name); } } } diff --git a/src/PepperDash.Essentials/HttpLogoServer.cs b/src/PepperDash.Essentials/HttpLogoServer.cs index 0ff60e93..1c7a4783 100644 --- a/src/PepperDash.Essentials/HttpLogoServer.cs +++ b/src/PepperDash.Essentials/HttpLogoServer.cs @@ -5,6 +5,7 @@ using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.Net.Http; using PepperDash.Core; +using Serilog.Events; namespace PepperDash.Essentials { @@ -61,7 +62,7 @@ namespace PepperDash.Essentials void Server_OnHttpRequest(object sender, OnHttpRequestArgs args) { var path = args.Request.Path; - Debug.Console(2, "HTTP Request with path: '{0}'", args.Request.Path); + Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "HTTP Request with path: '{requestPath:l}'", args.Request.Path); try { @@ -70,7 +71,7 @@ namespace PepperDash.Essentials var filePath = path.Replace('/', '\\'); var localPath = string.Format(@"{0}{1}", _fileDirectory, filePath); - Debug.Console(2, "HTTP Logo Server attempting to find file: '{0}'", localPath); + Debug.LogMessage(LogEventLevel.Verbose, "HTTP Logo Server attempting to find file: '{localPath:l}'", localPath); if (File.Exists(localPath)) { args.Response.Header.ContentType = GetContentType(new FileInfo(localPath).Extension); @@ -78,22 +79,22 @@ namespace PepperDash.Essentials } else { - Debug.Console(2, "HTTP Logo Server Cannot find file '{0}'", localPath); + Debug.LogMessage(LogEventLevel.Verbose, "HTTP Logo Server Cannot find file '{localPath:l}'", localPath); args.Response.ContentString = string.Format("Not found: '{0}'", filePath); args.Response.Code = 404; } } else { - Debug.Console(2, "HTTP Logo Server: '{0}' does not exist", _fileDirectory + path); + Debug.LogMessage(LogEventLevel.Verbose, "HTTP Logo Server: '{file:l}' does not exist", _fileDirectory + path); args.Response.ContentString = string.Format("Not found: '{0}'", _fileDirectory + path); args.Response.Code = 404; } } catch (Exception ex) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception getting file: {0}", ex.Message); - Debug.Console(0, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace); + Debug.LogMessage(LogEventLevel.Error, "Exception getting file: {exception}", ex.Message, ex.StackTrace); + Debug.LogMessage(LogEventLevel.Verbose, "Stack Trace: {stackTrace}", ex.StackTrace); args.Response.Code = 400; args.Response.ContentString = string.Format("invalid request"); diff --git a/src/PepperDash.Essentials/PepperDash.Essentials.csproj b/src/PepperDash.Essentials/PepperDash.Essentials.csproj index 98bfb710..70a2d2d4 100644 --- a/src/PepperDash.Essentials/PepperDash.Essentials.csproj +++ b/src/PepperDash.Essentials/PepperDash.Essentials.csproj @@ -47,7 +47,7 @@ - +