chore: remove deprecated Debug.Console methods

This commit is contained in:
Andrew Welker 2026-04-17 10:02:04 -05:00
parent 9ea5ec5d1a
commit 4a59cf9f81

View file

@ -5,6 +5,7 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core.Logging;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Core.Web
@ -25,29 +26,26 @@ namespace PepperDash.Core.Web
private readonly CCriticalSection _serverLock = new CCriticalSection();
private HttpCwsServer _server;
/// <summary>
/// Gets or sets the Key
/// </summary>
/// <summary>
/// Gets or sets the Key
/// </summary>
public string Key { get; private set; }
/// <summary>
/// Gets or sets the Name
/// </summary>
/// <summary>
/// Gets or sets the Name
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets or sets the BasePath
/// </summary>
/// <summary>
/// Gets or sets the BasePath
/// </summary>
public string BasePath { get; private set; }
/// <summary>
/// Gets or sets the IsRegistered
/// </summary>
/// <summary>
/// Gets or sets the IsRegistered
/// </summary>
public bool IsRegistered { get; private set; }
/// <summary>
/// Http request handler
/// </summary>
//public IHttpCwsHandler HttpRequestHandler
//{
// get { return _server.HttpRequestHandler; }
@ -58,9 +56,6 @@ namespace PepperDash.Core.Web
// }
//}
/// <summary>
/// Received request event handler
/// </summary>
//public event EventHandler<HttpCwsRequestEventArgs> ReceivedRequestEvent
//{
// add { _server.ReceivedRequestEvent += new HttpCwsRequestEventHandler(value); }
@ -91,7 +86,7 @@ namespace PepperDash.Core.Web
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="basePath"></param>
public WebApiServer(string key, string name, string basePath)
public WebApiServer(string key, string name, string basePath)
{
Key = key;
Name = string.IsNullOrEmpty(name) ? DefaultName : name;
@ -116,7 +111,7 @@ namespace PepperDash.Core.Web
{
if (programEventType != eProgramStatusEventType.Stopping) return;
Debug.Console(DebugInfo, this, "Program stopping. stopping server");
this.LogInformation("Program stopping. stopping server");
Stop();
}
@ -130,18 +125,18 @@ namespace PepperDash.Core.Web
// Re-enable the server if the link comes back up and the status should be connected
if (ethernetEventArgs.EthernetEventType == eEthernetEventType.LinkUp && IsRegistered)
{
Debug.Console(DebugInfo, this, "Ethernet link up. Server is alreedy registered.");
this.LogInformation("Ethernet link up. Server is alreedy registered.");
return;
}
Debug.Console(DebugInfo, this, "Ethernet link up. Starting server");
this.LogInformation("Ethernet link up. Starting server");
Start();
}
/// <summary>
/// Initialize method
/// </summary>
/// <summary>
/// Initialize method
/// </summary>
public void Initialize(string key, string basePath)
{
Key = key;
@ -155,7 +150,7 @@ namespace PepperDash.Core.Web
{
if (route == null)
{
Debug.Console(DebugInfo, this, "Failed to add route, route parameter is null");
this.LogWarning("Failed to add route, route parameter is null");
return;
}
@ -167,23 +162,20 @@ namespace PepperDash.Core.Web
/// Removes a route from CWS
/// </summary>
/// <param name="route"></param>
/// <summary>
/// RemoveRoute method
/// </summary>
public void RemoveRoute(HttpCwsRoute route)
{
if (route == null)
{
Debug.Console(DebugInfo, this, "Failed to remote route, orute parameter is null");
this.LogWarning("Failed to remove route, route parameter is null");
return;
}
_server.Routes.Remove(route);
}
/// <summary>
/// GetRouteCollection method
/// </summary>
/// <summary>
/// GetRouteCollection method
/// </summary>
public HttpCwsRouteCollection GetRouteCollection()
{
return _server.Routes;
@ -200,26 +192,24 @@ namespace PepperDash.Core.Web
if (_server == null)
{
Debug.Console(DebugInfo, this, "Server is null, unable to start");
this.LogWarning("Server is null, unable to start");
return;
}
if (IsRegistered)
{
Debug.Console(DebugInfo, this, "Server has already been started");
this.LogWarning("Server has already been started");
return;
}
IsRegistered = _server.Register();
Debug.Console(DebugInfo, this, "Starting server, registration {0}", IsRegistered ? "was successful" : "failed");
this.LogInformation("Starting server, registration {registrationResult}", IsRegistered ? "was successful" : "failed");
}
catch (Exception ex)
{
Debug.Console(DebugInfo, this, "Start Exception Message: {0}", ex.Message);
Debug.Console(DebugVerbose, this, "Start Exception StackTrace: {0}", ex.StackTrace);
if (ex.InnerException != null)
Debug.Console(DebugVerbose, this, "Start Exception InnerException: {0}", ex.InnerException);
this.LogError("Start Exception Message: {message}", ex.Message);
this.LogDebug(ex, "Start Exception StackTrace");
}
finally
{
@ -227,9 +217,9 @@ namespace PepperDash.Core.Web
}
}
/// <summary>
/// Stop method
/// </summary>
/// <summary>
/// Stop method
/// </summary>
public void Stop()
{
try
@ -238,23 +228,21 @@ namespace PepperDash.Core.Web
if (_server == null)
{
Debug.Console(DebugInfo, this, "Server is null or has already been stopped");
this.LogWarning("Server is null or has already been stopped");
return;
}
IsRegistered = _server.Unregister() == false;
Debug.Console(DebugInfo, this, "Stopping server, unregistration {0}", IsRegistered ? "failed" : "was successful");
this.LogInformation("Stopping server, unregistration {unregistrationResult}", IsRegistered ? "failed" : "was successful");
_server.Dispose();
_server = null;
}
catch (Exception ex)
{
Debug.Console(DebugInfo, this, "Server Stop Exception Message: {0}", ex.Message);
Debug.Console(DebugVerbose, this, "Server Stop Exception StackTrace: {0}", ex.StackTrace);
if (ex.InnerException != null)
Debug.Console(DebugVerbose, this, "Server Stop Exception InnerException: {0}", ex.InnerException);
this.LogError("Server Stop Exception Message: {message}", ex.Message);
this.LogDebug(ex, "Server Stop Exception StackTrace");
}
finally
{
@ -275,14 +263,12 @@ namespace PepperDash.Core.Web
try
{
var j = JsonConvert.SerializeObject(args.Context, Formatting.Indented);
Debug.Console(DebugVerbose, this, "RecieveRequestEventHandler Context:\x0d\x0a{0}", j);
this.LogVerbose("RecieveRequestEventHandler Context:\x0d\x0a{0}", j);
}
catch (Exception ex)
{
Debug.Console(DebugInfo, this, "ReceivedRequestEventHandler Exception Message: {0}", ex.Message);
Debug.Console(DebugVerbose, this, "ReceivedRequestEventHandler Exception StackTrace: {0}", ex.StackTrace);
if (ex.InnerException != null)
Debug.Console(DebugVerbose, this, "ReceivedRequestEventHandler Exception InnerException: {0}", ex.InnerException);
this.LogError("ReceivedRequestEventHandler Exception Message: {message}", ex.Message);
this.LogDebug(ex, "ReceivedRequestEventHandler Exception StackTrace: {stackTrace}", ex.StackTrace);
}
}
}