# Troubleshooting Guide This guide helps diagnose and resolve common issues with the Monolog GDPR Filter library. ## Table of Contents - [Installation Issues](#installation-issues) - [Pattern Matching Problems](#pattern-matching-problems) - [Performance Issues](#performance-issues) - [Memory Problems](#memory-problems) - [Integration Issues](#integration-issues) - [Audit Logging Issues](#audit-logging-issues) - [Error Messages Reference](#error-messages-reference) ## Installation Issues ### Composer Installation Fails **Symptom:** `composer require` fails with dependency conflicts. **Solution:** ```bash # Check PHP version php -v # Must be 8.2 or higher # Clear Composer cache composer clear-cache # Update Composer composer self-update # Try again with verbose output composer require ivuorinen/monolog-gdpr-filter -vvv ``` ### Class Not Found Errors **Symptom:** `Class 'Ivuorinen\MonologGdprFilter\GdprProcessor' not found` **Solutions:** 1. Regenerate autoloader: ```bash composer dump-autoload ``` 2. Verify installation: ```bash composer show ivuorinen/monolog-gdpr-filter ``` 3. Check namespace in your code: ```php validate($pattern); if (!$result['valid']) { echo "Invalid pattern: " . $result['error'] . "\n"; } // Test 2: Test pattern directly $testData = 'your test data with sensitive@email.com'; if (preg_match($pattern, $testData, $matches)) { echo "Pattern matches: " . print_r($matches, true); } else { echo "Pattern does not match\n"; } // Test 3: Test with processor $processor = new GdprProcessor([$pattern => '[MASKED]']); $record = [ 'message' => $testData, 'context' => [], 'level' => 200, 'level_name' => 'INFO', 'channel' => 'app', 'datetime' => new DateTimeImmutable(), 'extra' => [], ]; $result = $processor($record); echo "Result: " . $result['message'] . "\n"; ``` ### Pattern Matches Too Much **Symptom:** Non-sensitive data is being masked. **Solutions:** 1. Add word boundaries: ```php ['message' => $line, 'context' => []]; foreach ($streaming->processFile($largefile, $lineParser) as $record) { // Process one record at a time } ``` 2. Reduce recursion depth: ```php [ Ivuorinen\MonologGdprFilter\Laravel\GdprServiceProvider::class, ], ``` 2. Check logging configuration: ```php [ 'stack' => [ 'driver' => 'stack', 'channels' => ['gdpr'], ], 'gdpr' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'tap' => [GdprLogTap::class], ], ], ``` 3. Clear config cache: ```bash php artisan config:clear php artisan cache:clear ``` ### Monolog Integration **Symptom:** Processor not working with Monolog logger. **Solution:** Ensure processor is pushed to logger: ```php pushHandler(new StreamHandler('app.log')); $logger->pushProcessor(new GdprProcessor(DefaultPatterns::all())); // Test it $logger->info('User email: test@example.com'); ``` ### Symfony Integration See [Symfony Integration Guide](symfony-integration.md) for detailed setup. ## Audit Logging Issues ### Audit Logger Not Receiving Events **Symptom:** Audit callback never called. **Solutions:** 1. Verify audit logger is set: ```php 'No sensitive data here', 'context' => []]; // This won't trigger audit because nothing is masked ``` ### Rate-Limited Audit Missing Events **Symptom:** Some audit events are being dropped. **Solution:** Adjust rate limit settings: ```php addPattern('/valid-pattern/', '[MASKED]') ->build(); } catch (InvalidConfigurationException $e) { echo "Configuration error: " . $e->getMessage(); } ``` ## Getting Help If you're still experiencing issues: 1. **Check the tests:** The test suite contains many usage examples: ```bash ls tests/ ``` 2. **Enable debug mode:** Add verbose logging: ```php $masked"); }; ``` 3. **Report issues:** Open an issue on GitHub with: - PHP version (`php -v`) - Library version (`composer show ivuorinen/monolog-gdpr-filter`) - Minimal reproduction code - Expected vs actual behavior