mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix logging levels - use appropriate debug/info/warn/error levels
This commit is contained in:
@@ -23,7 +23,7 @@ public class WebSocketProxyMiddleware
|
||||
_settings = settings.Value;
|
||||
_logger = logger;
|
||||
|
||||
_logger.LogWarning("🔧 WEBSOCKET: WebSocketProxyMiddleware initialized - Jellyfin URL: {Url}", _settings.Url);
|
||||
_logger.LogDebug("🔧 WEBSOCKET: WebSocketProxyMiddleware initialized - Jellyfin URL: {Url}", _settings.Url);
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
@@ -38,7 +38,7 @@ public class WebSocketProxyMiddleware
|
||||
isWebSocket ||
|
||||
context.Request.Headers.ContainsKey("Upgrade"))
|
||||
{
|
||||
_logger.LogWarning("🔍 WEBSOCKET: Potential WebSocket request: Path={Path}, IsWs={IsWs}, Method={Method}, Upgrade={Upgrade}, Connection={Connection}",
|
||||
_logger.LogDebug("🔍 WEBSOCKET: Potential WebSocket request: Path={Path}, IsWs={IsWs}, Method={Method}, Upgrade={Upgrade}, Connection={Connection}",
|
||||
path,
|
||||
isWebSocket,
|
||||
context.Request.Method,
|
||||
@@ -50,7 +50,7 @@ public class WebSocketProxyMiddleware
|
||||
if (context.Request.Path.StartsWithSegments("/socket", StringComparison.OrdinalIgnoreCase) &&
|
||||
context.WebSockets.IsWebSocketRequest)
|
||||
{
|
||||
_logger.LogWarning("🔌 WEBSOCKET: WebSocket connection request received from {RemoteIp}",
|
||||
_logger.LogInformation("🔌 WEBSOCKET: WebSocket connection request received from {RemoteIp}",
|
||||
context.Connection.RemoteIpAddress);
|
||||
|
||||
await HandleWebSocketProxyAsync(context);
|
||||
@@ -70,7 +70,7 @@ public class WebSocketProxyMiddleware
|
||||
{
|
||||
// Accept the WebSocket connection from the client
|
||||
clientWebSocket = await context.WebSockets.AcceptWebSocketAsync();
|
||||
_logger.LogWarning("✓ WEBSOCKET: Client WebSocket accepted");
|
||||
_logger.LogDebug("✓ WEBSOCKET: Client WebSocket accepted");
|
||||
|
||||
// Build Jellyfin WebSocket URL
|
||||
var jellyfinUrl = _settings.Url?.TrimEnd('/') ?? "";
|
||||
@@ -84,7 +84,7 @@ public class WebSocketProxyMiddleware
|
||||
jellyfinWsUrl += context.Request.QueryString.Value;
|
||||
}
|
||||
|
||||
_logger.LogWarning("🔗 WEBSOCKET: Connecting to Jellyfin WebSocket: {Url}", jellyfinWsUrl);
|
||||
_logger.LogDebug("🔗 WEBSOCKET: Connecting to Jellyfin WebSocket: {Url}", jellyfinWsUrl);
|
||||
|
||||
// Connect to Jellyfin WebSocket
|
||||
serverWebSocket = new ClientWebSocket();
|
||||
@@ -94,7 +94,7 @@ public class WebSocketProxyMiddleware
|
||||
if (context.Request.Headers.TryGetValue("X-Emby-Authorization", out var embyAuthHeader))
|
||||
{
|
||||
serverWebSocket.Options.SetRequestHeader("X-Emby-Authorization", embyAuthHeader.ToString());
|
||||
_logger.LogWarning("🔑 WEBSOCKET: Forwarded X-Emby-Authorization header");
|
||||
_logger.LogDebug("🔑 WEBSOCKET: Forwarded X-Emby-Authorization header");
|
||||
}
|
||||
else if (context.Request.Headers.TryGetValue("Authorization", out var authHeader))
|
||||
{
|
||||
@@ -103,12 +103,12 @@ public class WebSocketProxyMiddleware
|
||||
if (authValue.Contains("MediaBrowser", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
serverWebSocket.Options.SetRequestHeader("X-Emby-Authorization", authValue);
|
||||
_logger.LogWarning("🔑 WEBSOCKET: Converted Authorization to X-Emby-Authorization header");
|
||||
_logger.LogDebug("🔑 WEBSOCKET: Converted Authorization to X-Emby-Authorization header");
|
||||
}
|
||||
else
|
||||
{
|
||||
serverWebSocket.Options.SetRequestHeader("Authorization", authValue);
|
||||
_logger.LogWarning("🔑 WEBSOCKET: Forwarded Authorization header");
|
||||
_logger.LogDebug("🔑 WEBSOCKET: Forwarded Authorization header");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class WebSocketProxyMiddleware
|
||||
serverWebSocket.Options.SetRequestHeader("User-Agent", "Allstarr/1.0");
|
||||
|
||||
await serverWebSocket.ConnectAsync(new Uri(jellyfinWsUrl), context.RequestAborted);
|
||||
_logger.LogWarning("✓ WEBSOCKET: Connected to Jellyfin WebSocket");
|
||||
_logger.LogInformation("✓ WEBSOCKET: Connected to Jellyfin WebSocket");
|
||||
|
||||
// Start bidirectional proxying
|
||||
var clientToServer = ProxyMessagesAsync(clientWebSocket, serverWebSocket, "Client→Server", context.RequestAborted);
|
||||
@@ -125,7 +125,7 @@ public class WebSocketProxyMiddleware
|
||||
// Wait for either direction to complete
|
||||
await Task.WhenAny(clientToServer, serverToClient);
|
||||
|
||||
_logger.LogWarning("🔌 WEBSOCKET: WebSocket proxy connection closed");
|
||||
_logger.LogDebug("🔌 WEBSOCKET: WebSocket proxy connection closed");
|
||||
}
|
||||
catch (WebSocketException wsEx)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ public class WebSocketProxyMiddleware
|
||||
clientWebSocket?.Dispose();
|
||||
serverWebSocket?.Dispose();
|
||||
|
||||
_logger.LogWarning("🧹 WEBSOCKET: WebSocket connections cleaned up");
|
||||
_logger.LogDebug("🧹 WEBSOCKET: WebSocket connections cleaned up");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class WebSocketProxyMiddleware
|
||||
|
||||
if (result.MessageType == WebSocketMessageType.Close)
|
||||
{
|
||||
_logger.LogWarning("🔌 WEBSOCKET {Direction}: Close message received", direction);
|
||||
_logger.LogDebug("🔌 WEBSOCKET {Direction}: Close message received", direction);
|
||||
await destination.CloseAsync(
|
||||
result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
|
||||
result.CloseStatusDescription,
|
||||
@@ -226,11 +226,11 @@ public class WebSocketProxyMiddleware
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.LogWarning("⚠️ WEBSOCKET {Direction}: Operation cancelled", direction);
|
||||
_logger.LogDebug("⚠️ WEBSOCKET {Direction}: Operation cancelled", direction);
|
||||
}
|
||||
catch (WebSocketException wsEx) when (wsEx.WebSocketErrorCode == WebSocketError.ConnectionClosedPrematurely)
|
||||
{
|
||||
_logger.LogWarning("⚠️ WEBSOCKET {Direction}: Connection closed prematurely", direction);
|
||||
_logger.LogDebug("⚠️ WEBSOCKET {Direction}: Connection closed prematurely", direction);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user