Cinder.Filter.Debug (Cinder v0.2.0)
View SourceDebugging 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 render performance and output size.
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
Logs filter callback execution with timing.
Examples
debug_callback("process/2", fn ->
# Your callback logic here
process_implementation(raw_value, column)
end)
Runs a comprehensive filter test suite.
Tests all callbacks with various inputs and logs results.
Examples
debug_comprehensive_test(MyApp.Filters.Slider)
Checks if debug mode is enabled.
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)
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
})
Logs render performance and output size.
Examples
debug_render_performance(MyApp.Filters.Slider, column, current_value, theme, assigns)
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})
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: []}}
])
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)
Disables debug mode for the current session.
Examples
iex> Cinder.Filter.Debug.disable_debug()
:ok
Enables debug mode for the current session.
Useful in IEx for temporary debugging.
Examples
iex> Cinder.Filter.Debug.enable_debug()
:ok