Skip to content

Commit e617970

Browse files
committed
Enhance logging and authentication handling
- Added a check to skip authentication for specific login and API paths, reducing unnecessary processing. - Adjusted logging levels for connection success messages in the background process and configured apps in settings manager to debug, improving log clarity and reducing verbosity.
1 parent b96a100 commit e617970

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/primary/auth.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,13 @@ def authenticate_request():
326326
recovery_key_path = "/auth/recovery-key"
327327
api_user_2fa_path = "/api/user/2fa/"
328328
api_settings_general_path = "/api/settings/general"
329+
330+
# Check if request is for login/auth paths (including Plex auth) - skip authentication
329331
if request.path.startswith((login_path, api_login_path, api_auth_plex_path, recovery_key_path, api_user_2fa_path)) or request.path == api_settings_general_path:
330332
if not is_polling_endpoint:
331333
# Reduced logging frequency for common paths to prevent spam
332-
if hash(request.path) % 20 == 0: # Log ~5% of auth skips
333-
logger.debug(f"Skipping authentication for login/plex/recovery/2fa/settings path '{request.path}'")
334+
if hash(request.path) % 20 == 0: # Log ~5% of auth skips
335+
logger.debug(f"Skipping authentication for login/plex/recovery/2fa/settings path '{request.path}'")
334336
return None
335337

336338
# If no user exists, redirect to setup

src/primary/background.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def app_specific_loop(app_type: str) -> None:
254254
if not connected:
255255
app_logger.warning(f"Failed to connect to {app_type} instance '{instance_name}' at {api_url}. Skipping.")
256256
continue
257-
app_logger.info(f"Successfully connected to {app_type} instance: {instance_name}")
257+
app_logger.debug(f"Successfully connected to {app_type} instance: {instance_name}")
258258
except Exception as e:
259259
app_logger.error(f"Error connecting to {app_type} instance '{instance_name}': {e}", exc_info=True)
260260
continue # Skip this instance if connection fails

src/primary/settings_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def get_configured_apps() -> List[str]:
304304
if settings.get("api_url") and settings.get("api_key"):
305305
configured.append(app_name)
306306

307-
settings_logger.info(f"Configured apps: {configured}")
307+
settings_logger.debug(f"Configured apps: {configured}")
308308
return configured
309309

310310
def apply_timezone(timezone: str) -> bool:

0 commit comments

Comments
 (0)