Cinder.Filter.Debug (Cinder v0.3.0)

View Source

Debugging tools for custom filter development.

This module provides utilities to help developers debug and test their custom filters during development.

Usage

Enable debug mode in your configuration:

config :cinder, debug_filters: true

Then use the debugging functions in your filter:

defmodule MyApp.Filters.CustomFilter do
  use Cinder.Filter
  import Cinder.Filter.Debug

  @impl true
  def process(raw_value, column) do
    debug_step("Processing input", %{raw_value: raw_value, column: column})

    result = # ... your processing logic

    debug_step("Process result", %{result: result})
    result
  end
end

Summary

Functions

Logs filter callback execution with timing.

Runs a comprehensive filter test suite.

Checks if debug mode is enabled.

Validates and logs filter processing pipeline.

Analyzes query building performance and logs the results.

Logs a debug step with context information.

Tests filter processing with sample inputs and logs results.

Validates a filter's callbacks and logs any issues.

Disables debug mode for the current session.

Enables debug mode for the current session.

Functions

debug_callback(callback_name, fun)

Logs filter callback execution with timing.

Examples

debug_callback("process/2", fn ->
  # Your callback logic here
  process_implementation(raw_value, column)
end)

debug_comprehensive_test(module)

Runs a comprehensive filter test suite.

Tests all callbacks with various inputs and logs results.

Examples

debug_comprehensive_test(MyApp.Filters.Slider)

debug_enabled?()

Checks if debug mode is enabled.

debug_pipeline(filter_name, raw_value, column, process_fun)

Validates and logs filter processing pipeline.

Useful for debugging the complete flow from raw input to final filter.

Examples

debug_pipeline("MyFilter", raw_value, column, fn ->
  MyFilter.process(raw_value, column)
end)

debug_query_building(module, field, filter_value)

Analyzes query building performance and logs the results.

Examples

debug_query_building(MyApp.Filters.Slider, "price", %{
  type: :slider,
  value: 100,
  operator: :less_than_or_equal
})

debug_render_performance(module, column, current_value, theme, assigns)

Logs render performance and output size.

Examples

debug_render_performance(MyApp.Filters.Slider, column, current_value, theme, assigns)

debug_step(message, context \\ %{})

Logs a debug step with context information.

Only logs when debug_filters is enabled in configuration.

Examples

debug_step("Validating input", %{input: "test", step: 1})

debug_test_inputs(module, test_cases)

Tests filter processing with sample inputs and logs results.

Useful for quick testing during development.

Examples

debug_test_inputs(MyApp.Filters.Slider, [
  {"50", %{filter_options: [min: 0, max: 100]}},
  {"invalid", %{filter_options: []}},
  {"", %{filter_options: []}}
])

debug_validate_filter(module)

Validates a filter's callbacks and logs any issues.

Useful during development to ensure all callbacks are properly implemented.

Examples

debug_validate_filter(MyApp.Filters.CustomFilter)

disable_debug()

Disables debug mode for the current session.

Examples

iex> Cinder.Filter.Debug.disable_debug()
:ok

enable_debug()

Enables debug mode for the current session.

Useful in IEx for temporary debugging.

Examples

iex> Cinder.Filter.Debug.enable_debug()
:ok