patrol_log package. This system provides structured, real-time feedback about test execution, making it easier to debug failures and understand test behavior.
Overview
Thepatrol_log package is used internally by Patrol CLI to capture and display test execution information. While you typically don’t need to interact with it directly, understanding how it works can help you debug tests more effectively.
Logging is automatically configured when you use
patrol test or patrol develop. The logs appear in your terminal as tests run.Log Structure
Patrol logs are structured as JSON entries that get parsed and formatted for display. Each log entry has a specific type:Entry Types
Test Entries
Mark the start, completion, failure, or skipping of individual tests.
Step Entries
Track individual test steps and actions within a test.
Log Entries
Custom log messages from your test code.
Error Entries
Capture errors and exceptions that occur during testing.
Warning Entries
Display warnings about configuration or test execution.
Config Entries
Store configuration information passed to the logging system.
Log Output Format
When you run Patrol tests, logs are displayed with emoji indicators for easy scanning:Log Components
Configuration Options
Patrol CLI provides several flags to control logging behavior:Show Flutter Logs
Capture and display Flutter framework logs:print() statements from your test code and framework debug output.
Hide Test Steps
Reduce output by hiding individual test steps:Clear Test Steps
Automatically clear successful test steps from the console:Hide Test Lifecycle
Hide test start/end messages:Test Summary
After all tests complete, Patrol displays a summary:Advanced: Custom Logging
While not commonly needed, you can use thepatrol_log package directly in custom tooling:
PatrolLogWriter
Creates and writes log entries:PatrolLogReader
Reads and parses log entries from test execution:The
patrol_log package is primarily for internal use by Patrol CLI. Most users don’t need to interact with it directly.Log Entry Details
Each log entry type has specific fields:Test Entry
Step Entry
Log Entry
Error Entry
Platform-Specific Logs
Patrol automatically parses platform-specific log formats:Android Logs
Android Logs
Patrol captures Flutter logs from logcat with the pattern:
iOS Logs
iOS Logs
Captures logs from the iOS console:Release mode uses a simpler format:
Web Logs
Web Logs
Captures Playwright logs for web testing:
Troubleshooting
No logs appearing
No logs appearing
Ensure you’re running tests with
patrol test or patrol develop, not flutter test. Patrol CLI is required for log capture.Logs are cluttered
Logs are cluttered
Use
--clear-test-steps to automatically remove successful step logs, or --no-test-steps to hide them entirely.Missing Flutter logs
Missing Flutter logs
Add the
--verbose flag to patrol test to enable Flutter framework logging.Can't find failed test location
Can't find failed test location
Failed tests are listed in the summary with their full file paths. Look for the ❌ section in the test summary.
Best Practices
Keep test steps visible during development
Don’t hide test steps while developing tests. They provide valuable debugging information.
Use clear test steps in CI
In CI environments, use
--clear-test-steps to reduce log output while preserving failure information.Next Steps
VS Code Extension
View logs in real-time with the VS Code extension.
CI Configuration
Configure logging for CI environments.
Debugging Tests
Learn advanced debugging techniques.
Writing Tests
Start writing Patrol tests.