Repo rules
- This provisioning code is designed to run on Manjaro Linux.
This project uses a custom Logger class instead of `print()` and `debugPrint()` statements. The logger provides structured, categorized, and colorized logging with different levels and categories.
Sign in to like and favorite skills
- This provisioning code is designed to run on Manjaro Linux.
.llmrules
Code Style and Structure
This project uses a custom Logger class instead of
print() and debugPrint() statements. The logger provides structured, categorized, and colorized logging with different levels and categories.
Always import the logger at the top of your files:
import 'package:pupilica_hackathon/core/helpers/logger/logger.dart';
Debugging Information
Error Handling
User Flow Tracking
Performance Monitoring
Business Logic Events
// For development debugging Logger.debug('User tapped login button', category: LogCategory.ui); Logger.debug('API response received', category: LogCategory.api, data: {'status': 200, 'data': responseData});
// For general information Logger.info('User successfully logged in', category: LogCategory.auth); Logger.info('Navigation to home screen', category: LogCategory.navigation);
// For potential issues Logger.warning('API response time exceeded 5 seconds', category: LogCategory.api); Logger.warning('Low memory detected', category: LogCategory.general);
// For errors and exceptions try { // Some operation } catch (e, stackTrace) { Logger.error('Failed to process OCR image', category: LogCategory.ocr, error: e, stackTrace: stackTrace); } // For API errors Logger.error('Login failed', category: LogCategory.auth, data: {'error_code': 401, 'message': 'Invalid credentials'});
// For successful operations Logger.success('OCR processing completed successfully', category: LogCategory.ocr); Logger.success('Data saved to database', category: LogCategory.database);
Use appropriate categories for better log organization:
LogCategory.splash - Splash screen related logsLogCategory.navigation - Navigation and routing logsLogCategory.api - API calls and responsesLogCategory.database - Database operationsLogCategory.ui - UI interactions and state changesLogCategory.auth - Authentication and authorizationLogCategory.ocr - OCR processing and image analysisLogCategory.general - General purpose logs// ❌ Wrong - using print Future<FutureOr<void>> _onLoginEvent( LoginEvent event, Emitter<LoginState> emit, ) async { print('Login event received'); // ❌ Don't use print // ... logic } // ✅ Correct - using Logger Future<FutureOr<void>> _onLoginEvent( LoginEvent event, Emitter<LoginState> emit, ) async { Logger.info('Login event received', category: LogCategory.auth); // ... logic }
// ❌ Wrong - using print for errors try { await apiCall(); } catch (e) { print('Error: $e'); // ❌ Don't use print for errors } // ✅ Correct - using Logger try { await apiCall(); } catch (e, stackTrace) { Logger.error('API call failed', category: LogCategory.api, error: e, stackTrace: stackTrace); }
// ❌ Wrong - using debugPrint void _onButtonPressed() { debugPrint('Button pressed'); // ❌ Don't use debugPrint setState(() { // state change }); } // ✅ Correct - using Logger void _onButtonPressed() { Logger.debug('Button pressed', category: LogCategory.ui); setState(() { // state change }); }
// ❌ Wrong - using print Future<ApiResponse> fetchData() async { print('Fetching data from API'); // ❌ Don't use print final response = await http.get(uri); print('Response: ${response.body}'); // ❌ Don't use print return ApiResponse.fromJson(jsonDecode(response.body)); } // ✅ Correct - using Logger Future<ApiResponse> fetchData() async { Logger.info('Fetching data from API', category: LogCategory.api); final response = await http.get(uri); Logger.debug('API response received', category: LogCategory.api, data: {'status_code': response.statusCode, 'body_length': response.body.length}); return ApiResponse.fromJson(jsonDecode(response.body)); }
LogCategory.general only when no other category fits// ❌ Poor message Logger.debug('test', category: LogCategory.general); // ✅ Good message Logger.debug('User profile loaded successfully', category: LogCategory.ui);
// ✅ Include relevant data for debugging Logger.debug('OCR processing started', category: LogCategory.ocr, data: { 'image_size': '${image.width}x${image.height}', 'processing_time': '${DateTime.now().millisecondsSinceEpoch}' });
// ✅ Always include error and stack trace for exceptions try { // risky operation } catch (e, stackTrace) { Logger.error('Operation failed', category: LogCategory.general, error: e, stackTrace: stackTrace, data: {'operation': 'data_processing', 'user_id': userId}); }
// ✅ Log performance metrics final stopwatch = Stopwatch()..start(); // ... operation stopwatch.stop(); Logger.info('Operation completed', category: LogCategory.general, data: {'duration_ms': stopwatch.elapsedMilliseconds});
When refactoring existing code:
The logger provides structured output with:
Example output:
[2024-01-15T10:30:45.123Z] Pupilica AI 🚀 SPLASH ℹ️ INFO: Splash screen initialized [2024-01-15T10:30:45.456Z] Pupilica AI 🌐 API 🐛 DEBUG: API request sent | Data: {url: /api/login, method: POST}
This structured approach makes debugging much more efficient and provides better insights into application behavior.