flutter_live_logger 0.3.0 copy "flutter_live_logger: ^0.3.0" to clipboard
flutter_live_logger: ^0.3.0 copied to clipboard

Production-ready real-time logging for Flutter with offline support, performance monitoring, and dashboard UI. Features 400K+ logs/sec throughput.

Flutter Live Logger #

pub package pub points popularity likes License: MIT style: flutter_lints

Production-ready real-time logging for Flutter with offline support, performance monitoring, and dashboard UI. Features 400K+ logs/sec throughput.

Flutter Live Logger is a comprehensive logging library designed for Flutter apps in production. It provides multiple transport layers, persistent storage, automatic navigation tracking, and offline support with a clean, developer-friendly API.

๐Ÿ“– Languages: English โ€ข ํ•œ๊ตญ์–ด


โœจ Features #

๐ŸŽฏ Core Capabilities #

  • ๐Ÿš€ High Performance: 400,000+ logs/second throughput
  • ๐ŸŒ Cross-Platform: iOS, Android, Web, macOS, Windows, Linux
  • ๐Ÿ”ฅ Multiple Transport Layers: Memory, File, HTTP transport options
  • ๐Ÿ’พ Persistent Storage: SQLite and memory-based storage with querying
  • ๐Ÿ“ฑ Auto Navigation Tracking: Automatic screen transition logging
  • ๐Ÿ”„ Offline Support: Queue logs offline and sync when connected
  • โšก Smart Batching: Configurable batching for efficiency
  • ๐ŸŽ›๏ธ Configurable: Multiple environment configurations (dev/prod/test)

๐Ÿ› ๏ธ Developer Experience #

  • โšก Easy Setup: Initialize with one line of code
  • ๐Ÿ“š Complete API: Comprehensive dartdoc documentation
  • ๐Ÿ”’ Type Safe: Full null safety and strong typing
  • ๐Ÿงช Well Tested: 95%+ test coverage with 35+ comprehensive tests
  • ๐ŸŒ Cross Platform: iOS, Android, Web, Desktop support

๐Ÿš€ Quick Start #

Installation #

dependencies:
  flutter_live_logger: ^0.3.0

๐Ÿ”ฅ Zero-Configuration Start (New in 0.3.0!) #

import 'package:flutter_live_logger/flutter_live_logger.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // ๐Ÿš€ One line to start - that's it!
  await FlutterLiveLogger.start();
  
  runApp(MyApp());
}

The logger automatically configures itself with sensible defaults for your environment.

๐ŸŽฏ Environment-Specific Configurations #

// Development (verbose logging, console output)
await FlutterLiveLogger.startDevelopment();

// Production (optimized performance, file storage)
await FlutterLiveLogger.startProduction();

// Custom configuration
await FlutterLiveLogger.init(
  config: LoggerConfig.production(
    transports: [
      HttpTransport(config: HttpTransportConfig(
        endpoint: 'https://your-api.com/logs',
        apiKey: 'your-api-key',
      )),
      FileTransport(config: FileTransportConfig(
        directory: '/app/logs',
        compressRotatedFiles: true,
      )),
    ],
  ),
);

Logging Messages #

// Simple logging
FlutterLiveLogger.info('User logged in');
FlutterLiveLogger.error('Payment failed');

// With structured data
FlutterLiveLogger.event('purchase', {
  'item': 'Premium',
  'price': 9.99,
});

3. Add Navigation Tracking #

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'My App',
      navigatorObservers: [
        FlutterLiveLoggerNavigatorObserver(
          enableDurationTracking: true,
          enableBreadcrumbs: true,
        ),
      ],
      home: HomeScreen(),
    );
  }
}

4. Start Logging #

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Flutter Live Logger Demo')),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            // Simple logging
            FlutterLiveLogger.info('User clicked button');
            
            // Event tracking with structured data
            FlutterLiveLogger.event('button_click', {
              'button_id': 'main_cta',
              'screen': 'home',
              'timestamp': DateTime.now().toIso8601String(),
            });
            
            // Error logging with context
            try {
              throw Exception('Demo error');
            } catch (error, stackTrace) {
              FlutterLiveLogger.error(
                'Operation failed',
                data: {'operation': 'demo'},
                error: error,
                stackTrace: stackTrace,
              );
            }
          },
          child: Text('Test Logging'),
        ),
      ),
    );
  }
}

๐Ÿ’ก Real-World Examples #

๐Ÿ›’ E-commerce App Logging #

// Track user journey
FlutterLiveLogger.event('user_session_start', {
  'user_id': currentUser.id,
  'session_id': sessionManager.currentSession,
  'app_version': packageInfo.version,
});

// Product interactions
FlutterLiveLogger.info('Product viewed', data: {
  'product_id': product.id,
  'category': product.category,
  'price': product.price,
  'source': 'search_results',
});

// Purchase flow
FlutterLiveLogger.event('purchase_initiated', {
  'cart_value': cart.totalValue,
  'item_count': cart.items.length,
  'payment_method': selectedPaymentMethod,
});

// Error handling
try {
  await paymentService.processPayment(paymentData);
} catch (error, stackTrace) {
  FlutterLiveLogger.error(
    'Payment processing failed',
    data: {
      'user_id': currentUser.id,
      'amount': paymentData.amount,
      'currency': paymentData.currency,
      'payment_method': paymentData.method,
    },
    error: error,
    stackTrace: stackTrace,
  );
}

๐Ÿฅ Healthcare App Monitoring #

// Performance monitoring for critical operations
final stopwatch = Stopwatch()..start();
try {
  final patientData = await healthService.getPatientData(patientId);
  stopwatch.stop();
  
  FlutterLiveLogger.info('Patient data loaded', data: {
    'patient_id': patientId,
    'data_size': patientData.records.length,
    'load_time_ms': stopwatch.elapsedMilliseconds,
    'cache_hit': patientData.fromCache,
  });
} catch (error, stackTrace) {
  stopwatch.stop();
  FlutterLiveLogger.error(
    'Failed to load patient data',
    data: {
      'patient_id': patientId,
      'attempt_duration_ms': stopwatch.elapsedMilliseconds,
    },
    error: error,
    stackTrace: stackTrace,
  );
}

๐ŸŽฎ Gaming App Analytics #

// Game session tracking
FlutterLiveLogger.event('game_session_start', {
  'level': currentLevel,
  'character': selectedCharacter,
  'difficulty': gameDifficulty,
});

// Performance metrics
FlutterLiveLogger.event('frame_rate_sample', {
  'fps': fpsCounter.currentFPS,
  'avg_fps': fpsCounter.averageFPS,
  'min_fps': fpsCounter.minimumFPS,
  'scene': currentScene.name,
});

// User achievements
FlutterLiveLogger.event('achievement_unlocked', {
  'achievement_id': achievement.id,
  'achievement_name': achievement.name,
  'unlock_time': DateTime.now().toIso8601String(),
  'player_level': player.level,
  'total_playtime_minutes': player.totalPlayTime.inMinutes,
});

๐Ÿ“– Advanced Usage #

Configuration Options #

// Development Configuration
await FlutterLiveLogger.init(
  config: LoggerConfig(
    logLevel: LogLevel.debug,
    environment: 'development',
    enableOfflineSupport: true,
    transports: [
      MemoryTransport(maxEntries: 1000),
      HttpTransport(
        config: HttpTransportConfig.withApiKey(
          endpoint: 'https://api.example.com/logs',
          apiKey: 'dev-api-key',
        ),
      ),
    ],
  ),
);

// Production Configuration  
await FlutterLiveLogger.init(
  config: LoggerConfig(
    logLevel: LogLevel.info,
    environment: 'production',
    enableOfflineSupport: true,
    batchSize: 50,
    flushInterval: Duration(seconds: 10),
    transports: [
      HttpTransport(
        config: HttpTransportConfig.withApiKey(
          endpoint: 'https://api.example.com/logs',
          apiKey: 'prod-api-key',
          batchSize: 50,
          timeout: Duration(seconds: 30),
          maxRetries: 3,
        ),
      ),
      FileTransport(
        config: FileTransportConfig(
          directory: '/app/logs',
          maxFileSize: 10 * 1024 * 1024, // 10MB
          maxFiles: 5,
        ),
      ),
    ],
  ),
);

Transport Layers #

// Memory Transport (for development/testing)
final memoryTransport = MemoryTransport(
  maxEntries: 1000,
);

// File Transport (for local persistence)
final fileTransport = FileTransport(
  config: FileTransportConfig(
    directory: '/app/logs',
    filePrefix: 'app_log',
    maxFileSize: 10 * 1024 * 1024, // 10MB
    maxFiles: 5,
    enableRotation: true,
  ),
);

// HTTP Transport (for remote logging with full web support)
final httpTransport = HttpTransport(
  config: HttpTransportConfig.withApiKey(
    endpoint: 'https://api.example.com/logs',
    apiKey: 'your-api-key',
    batchSize: 10,
    timeout: Duration(seconds: 30),
    maxRetries: 3,
  ),
);

Storage Options #

// Memory Storage (fast, non-persistent)
final memoryStorage = MemoryStorage(maxEntries: 10000);

// SQLite Storage (persistent, queryable)
final sqliteStorage = SQLiteStorage(
  path: 'app_logs.db',
  maxEntries: 100000,
);

๐ŸŒ Web Platform Support #

Flutter Live Logger fully supports web platforms with CORS-enabled HTTP transport:

// Works seamlessly on web
HttpTransport(
  config: HttpTransportConfig.withApiKey(
    endpoint: 'https://api.example.com/logs',
    apiKey: 'your-key',
  ),
)

Note: Server must have proper CORS headers configured:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Origin, Content-Type, X-API-Key

๐Ÿ“Š Performance Benchmarks #

Benchmarked performance metrics:

  • Throughput: 434,783 logs/second
  • Initialization: <50ms startup time
  • Memory: <10MB peak usage
  • Cross-platform: Consistent performance across all platforms

๐Ÿ“Š Dashboard Integration #

For real-time monitoring and analytics, use the companion dashboard:

dev_dependencies:
  flutter_live_logger_dashboard: ^0.2.0

๐Ÿ“ฑ Platform Support #

Platform Support Notes
iOS โœ… Full support
Android โœ… Full support
Web โœ… CORS required for HTTP transport
macOS โœ… Full support
Windows โœ… Full support
Linux โœ… Full support

๐Ÿงช Testing #

The package includes comprehensive test coverage:

flutter test

Test Results: 35/35 tests passing (100%)

๐Ÿ“š Examples #

Check out the example app for a complete implementation showing:

  • Basic logging setup
  • HTTP transport configuration (web compatible)
  • Navigator observation
  • Error handling
  • Performance monitoring

๐Ÿค Contributing #

We welcome contributions! Please see our Contributing Guide for details.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“ž Support #

0
likes
160
points
217
downloads

Publisher

verified publishercurogom.dev

Weekly Downloads

Production-ready real-time logging for Flutter with offline support, performance monitoring, and dashboard UI. Features 400K+ logs/sec throughput.

Repository (GitHub)
View/report issues
Contributing

Topics

#logging #monitoring #debugging #analytics #performance

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, http, path, sqflite

More

Packages that depend on flutter_live_logger