Skip to content

Refactor: Standardize and Improve Logging Consistency #19

@fred-maina

Description

@fred-maina

Description

Logging is inconsistent across the application. Some log messages are unhelpful, and log levels are not always used appropriately.

Examples:

  1. Unhelpful message: In AuthController.checkUsername, the log log.error("username {} not found for some weird reason", username); is not professional or helpful for debugging. It should be a log.warn or log.info stating the username was checked and not found.
  2. Inconsistent Levels: Some debug-level information is logged at INFO (e.g., in ChatWebSocketHandler).
  3. Missing Logs: Critical paths, like the default case in ChatWebSocketHandler.handleTextMessage, log a warning but could be more verbose about the payload received.

Acceptance Criteria

  1. Audit all log statements in the project.
  2. Standardize log levels:
    • ERROR: For unrecoverable errors (e.g., database connection failure, unhandled exceptions in ControllerAdvice).
    • WARN: For recoverable issues or potential problems (e.g., invalid auth token, user not found, unhandled WebSocket message type).
    • INFO: For major lifecycle events (e.g., application started, user logged in, new user registered, session connected/disconnected).
    • DEBUG: For granular, high-volume information (e.g., "message received", "checking cache", "sending token request").
  3. Rewrite unhelpful messages: Change messages like "...for some weird reason" to be professional and state the facts.
  4. Ensure all exceptions are logged with the stack trace at the ERROR or WARN level.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions