Skip to content

Debug Mode with Console Logging #66

@palcarazm

Description

@palcarazm

Short Description of the Feature

Add an optional debug mode that logs detailed information to the browser console, including initialization steps, state changes, storage operations, and any errors or warnings. Debug mode is disabled by default.

Expected Benefits

  • Greatly simplifies troubleshooting for developers integrating the plugin
  • Reduces support burden (users can enable debug and share logs)
  • Helps identify edge cases and bugs during development
  • Provides transparency about plugin behavior
  • Standard practice for professional open-source libraries

Acceptance Criteria

  • New debug: boolean option (default: false)
  • When debug: true, all internal operations are logged with consistent prefix: [DarkModeToggle]
  • Logs include: initialization, option resolution, storage reads/writes, state changes, event emissions
  • Errors and warnings are always logged regardless of debug mode (but with clear formatting)
  • Logs can be filtered by log level (info, warn, error)
  • Documentation includes examples of enabling debug and interpreting logs
  • Debug mode does not impact performance in production (disabled by default)

Documentation

Enabling debug mode:

bsDarkmodeToggle({
  debug: true,
  storage: "local"
});
<div data-plugin="bs-darkmode-toggle" data-debug></div>

Additional Comments

Implementation should use a simple log(message, level) method that checks this.options.debug before outputting. Consider using console.group() for complex operations to improve readability.

Feature Request Checklist

  • Confirm that you agree to follow the project's code of conduct.
  • Confirm that you have reviewed open and rejected feature requests to ensure novelty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions