strategic_logger 1.1.1 copy "strategic_logger: ^1.1.1" to clipboard
strategic_logger: ^1.1.1 copied to clipboard

[pending analysis]

Modern, high-performance logging framework for Flutter & Dart applications with multi-strategy logging, isolate-based processing, and beautiful console output.

Strategic Logger πŸš€ #

Pub Version License: MIT Flutter Dart MCP AI-Powered

The future of logging is here: AI-powered, MCP-native, high-performance logging framework

Strategic Logger is the first logging framework to integrate Model Context Protocol (MCP) and AI-powered analysis, combining multi-strategy logging, isolate-based processing, and intelligent log insights to revolutionize how developers handle application logs.


✨ Why Strategic Logger? #

πŸ€– MCP-Native Integration #

  • Model Context Protocol support for AI agent integration
  • Native MCP server with HTTP endpoints for log querying
  • Real-time log streaming to AI agents and tools
  • Structured context for intelligent log analysis

🧠 AI-Powered Intelligence #

  • Intelligent log analysis with pattern detection
  • Automated insights and recommendations
  • Anomaly detection for proactive monitoring
  • Smart log summarization for faster debugging

⚑ Performance First #

  • Isolate-based processing - Never block the main thread
  • Async queue with backpressure - Handle high log volumes efficiently
  • Object pooling - Optimized memory management
  • Log compression - Reduce network and storage overhead

🎯 One Call, All Strategies #

Log once and send to multiple destinations simultaneously - Console, Firebase, Sentry, Datadog, New Relic, MCP, and AI analysis.

🎨 Beautiful Console Output #

  • Modern formatting with colors, emojis, and structured layout
  • Rich context display with metadata and stack traces
  • Timestamp precision with millisecond accuracy

πŸ”„ Drop-in Replacement #

100% compatible with popular logger packages - no code changes required!


πŸš€ Quick Start #

Installation #

Add Strategic Logger to your pubspec.yaml:

dependencies:
  strategic_logger: ^1.1.0

Then run:

flutter pub get

Basic Usage #

import 'package:strategic_logger/strategic_logger.dart';

void main() async {
  // Initialize once at app startup
  await logger.initialize(
    level: LogLevel.debug,
    strategies: [
      ConsoleLogStrategy(
        useModernFormatting: true,
        useColors: true,
        useEmojis: true,
      ),
      // MCP Strategy for AI agent integration
      MCPLogStrategy(port: 3000),
      // AI Strategy for intelligent analysis
      AILogStrategy(),
      // Traditional strategies
      FirebaseAnalyticsLogStrategy(),
      FirebaseCrashlyticsLogStrategy(),
    ],
    useIsolates: true,
    enablePerformanceMonitoring: true,
  );

  // Start logging!
  await logger.info('App started successfully');
  await logger.error('Something went wrong', stackTrace: StackTrace.current);
}

🎯 Features #

πŸ€– MCP (Model Context Protocol) Features #

  • Native MCP Server - Built-in HTTP server for AI agent integration
  • Real-time Log Streaming - Stream logs directly to AI agents and tools
  • Structured Context API - Rich metadata for intelligent log analysis
  • Health Monitoring - Built-in health endpoints and metrics
  • Query Interface - Advanced log querying with filtering and search
  • WebSocket Support - Real-time bidirectional communication

🧠 AI-Powered Features #

  • Intelligent Log Analysis - Automated pattern detection and anomaly identification
  • Smart Insights - AI-generated recommendations and actionable insights
  • Automated Summarization - Intelligent log summarization for faster debugging
  • Predictive Analytics - Proactive monitoring with predictive insights
  • Context-Aware Processing - AI understands log context and relationships
  • Natural Language Queries - Query logs using natural language

πŸ”§ Core Features #

  • Multiple Log Strategies - Console, Firebase, Sentry, Datadog, New Relic, MCP, AI
  • Custom Strategies - Extend with your own logging destinations
  • Log Levels - Debug, Info, Warning, Error, Fatal with intelligent routing
  • Structured Logging - Rich metadata and context support
  • Error Handling - Robust error management with predefined types

πŸš€ Performance Features #

  • Isolate Processing - Heavy operations run in background isolates
  • Object Pooling - Optimized memory management for high-performance apps
  • Log Compression - Intelligent compression to reduce network and storage overhead
  • Performance Monitoring - Built-in metrics and performance tracking
  • Async Queue - Efficient log processing with backpressure control
  • Batch Processing - Automatic batching for network strategies
  • Retry Logic - Exponential backoff for failed operations

🎨 Developer Experience #

  • Modern Console - Beautiful, colorful, emoji-rich output
  • Compatibility Layer - Drop-in replacement for popular logger packages
  • Type Safety - Full TypeScript-style type safety in Dart
  • Hot Reload - Seamless development experience with Flutter
  • Documentation - Comprehensive API documentation and examples

πŸ€– MCP (Model Context Protocol) Integration #

Strategic Logger is the first logging framework to natively support the Model Context Protocol, enabling seamless integration with AI agents and intelligent tools.

MCP Server Features #

// Initialize MCP strategy
final mcpStrategy = MCPLogStrategy(
  port: 3000,
  host: 'localhost',
  maxHistorySize: 10000,
);

// Start the MCP server
await mcpStrategy.startServer();

// Log with MCP context
await mcpStrategy.info(
  message: 'User authentication successful',
  context: {
    'userId': '12345',
    'sessionId': 'abc-def-ghi',
    'timestamp': DateTime.now().toIso8601String(),
  },
);

// Get health status
final health = await mcpStrategy.getHealthStatus();
print('MCP Server Health: $health');

AI Agent Integration #

// Initialize AI strategy for intelligent analysis
final aiStrategy = AILogStrategy(
  analysisInterval: Duration(minutes: 5),
  batchSize: 100,
  enableInsights: true,
);

// Start AI analysis
await aiStrategy.startAnalysis();

// Log with AI context
await aiStrategy.error(
  message: 'Database connection failed',
  context: {
    'database': 'users_db',
    'retryCount': 3,
    'lastError': 'Connection timeout',
  },
);

// Generate intelligent summary
final summary = await aiStrategy.generateLogSummary();
print('AI Analysis: $summary');

MCP Endpoints #

The MCP server provides several HTTP endpoints for AI agent integration:

  • GET /health - Server health and metrics
  • GET /logs - Retrieve recent logs with filtering
  • POST /query - Advanced log querying
  • WebSocket /stream - Real-time log streaming

πŸ“– Usage Examples #

// Basic logging
await logger.debug('Debug message');
await logger.info('Info message');
await logger.warning('Warning message');
await logger.error('Error message');
await logger.fatal('Fatal error');

// Structured logging with context
await logger.info('User action', context: {
  'userId': '123',
  'action': 'login',
  'timestamp': DateTime.now().toIso8601String(),
});

// Log with events
await logger.log('User logged in', event: LogEvent(
  eventName: 'user_login',
  eventMessage: 'User successfully logged in',
  parameters: {'userId': '123'},
));

Sync Logging (Compatibility) #

// Drop-in replacement for popular logger packages
logger.debugSync('Debug message');
logger.infoSync('Info message');
logger.errorSync('Error message');

// Or use the compatibility extension
loggerCompatibility.debug('Debug message');
loggerCompatibility.info('Info message');
loggerCompatibility.error('Error message');

Performance Monitoring #

// Get performance statistics
final stats = logger.getPerformanceStats();
print('Performance Stats: $stats');

// Force flush all queued logs
logger.flush();

Object Pooling & Memory Optimization #

// Initialize object pool for memory optimization
final objectPool = ObjectPool();
await objectPool.initialize();

// Get pooled objects (automatically managed)
final logEntry = objectPool.getLogEntry();
final context = objectPool.getContextMap();

// Use objects...
logEntry.message = 'Optimized logging';
context['userId'] = '12345';

// Return to pool (automatic cleanup)
objectPool.returnLogEntry(logEntry);
objectPool.returnContextMap(context);

// Get pool statistics
final poolStats = objectPool.getStats();
print('Pool Stats: $poolStats');

Log Compression #

// Initialize log compression
final compression = LogCompression();
await compression.startCompression();

// Add logs for compression
for (int i = 0; i < 1000; i++) {
  await compression.addLogEntry(CompressibleLogEntry(
    message: 'Log entry $i',
    level: LogLevel.info,
    timestamp: DateTime.now(),
    context: {'iteration': i},
  ));
}

// Get compression statistics
final compressionStats = compression.getStats();
print('Compression Stats: $compressionStats');

🎨 Modern Console Output #

Experience beautiful, structured console output:

πŸ› 14:30:25.123 DEBUG  User action completed
πŸ“‹ Event: USER_ACTION
   Message: User completed purchase
   Parameters:
     userId: 123
     amount: 99.99
πŸ” Context:
   timestamp: 2024-01-15T14:30:25.123Z
   source: mobile_app

πŸ”§ Configuration #

Advanced Initialization #

await logger.initialize(
  level: LogLevel.info,
  strategies: [
    // Console with modern formatting
    ConsoleLogStrategy(
      useModernFormatting: true,
      useColors: true,
      useEmojis: true,
      showTimestamp: true,
      showContext: true,
    ),
    
    // Firebase Analytics
    FirebaseAnalyticsLogStrategy(),
    
    // Firebase Crashlytics
    FirebaseCrashlyticsLogStrategy(),
    
    // Datadog
    DatadogLogStrategy(
      apiKey: 'your-datadog-api-key',
      service: 'my-app',
      env: 'production',
      tags: 'team:mobile,version:1.0.0',
    ),
    
    // New Relic
    NewRelicLogStrategy(
      licenseKey: 'your-newrelic-license-key',
      appName: 'my-app',
      environment: 'production',
    ),
  ],
  
  // Modern features
  useIsolates: true,
  enablePerformanceMonitoring: true,
  enableModernConsole: true,
);

Custom Strategies #

Create your own logging strategy:

class MyCustomLogStrategy extends LogStrategy {
  @override
  Future<void> log({dynamic message, LogEvent? event}) async {
    // Use isolates for heavy processing
    final result = await isolateManager.executeInIsolate(
      'customTask',
      {'message': message, 'event': event?.toMap()},
    );
    
    // Send to your custom service
    await _sendToCustomService(result);
  }
  
  @override
  Future<void> info({dynamic message, LogEvent? event}) async {
    await log(message: message, event: event);
  }
  
  @override
  Future<void> error({dynamic error, StackTrace? stackTrace, LogEvent? event}) async {
    await log(message: error, event: event);
  }
  
  @override
  Future<void> fatal({dynamic error, StackTrace? stackTrace, LogEvent? event}) async {
    await log(message: error, event: event);
  }
}

πŸ“Š Performance #

Strategic Logger is designed for high performance:

  • Isolate-based processing prevents blocking the main thread
  • Automatic batching reduces network overhead
  • Async queue with backpressure handles high log volumes
  • Performance monitoring tracks operation metrics
  • Efficient serialization minimizes memory usage

Performance Metrics #

final stats = logger.getPerformanceStats();
print('Total operations: ${stats['processLogEntry']?.totalOperations}');
print('Average duration: ${stats['processLogEntry']?.averageDuration}ms');
print('Error rate: ${stats['processLogEntry']?.errorRate}%');

πŸ†• Migration Guide #

From v0.1.x to v0.2.x #

The new version introduces breaking changes for better performance and modern features:

// Old way (v0.1.x)
logger.initialize(
  level: LogLevel.info,
  strategies: [ConsoleLogStrategy()],
);

// New way (v0.2.x)
await logger.initialize(
  level: LogLevel.info,
  strategies: [
    ConsoleLogStrategy(
      useModernFormatting: true,
      useColors: true,
      useEmojis: true,
    ),
  ],
  useIsolates: true,
  enablePerformanceMonitoring: true,
  enableModernConsole: true,
);

🌐 Supported Platforms #

  • βœ… Flutter (iOS, Android, Web, Desktop)
  • βœ… Dart CLI applications
  • βœ… Dart VM applications
  • βœ… Flutter Web
  • βœ… Flutter Desktop (Windows, macOS, Linux)

🎯 Use Cases & Applications #

🏒 Enterprise Applications #

  • Microservices Architecture - Centralized logging across distributed systems
  • High-Traffic Applications - Handle millions of logs with isolate-based processing
  • Real-time Monitoring - AI-powered anomaly detection and alerting
  • Compliance & Auditing - Structured logging for regulatory requirements

πŸ€– AI & Machine Learning #

  • Model Context Protocol - Native integration with AI agents and tools
  • Intelligent Log Analysis - Automated pattern detection and insights
  • Predictive Monitoring - Proactive issue detection and prevention
  • Natural Language Queries - Query logs using conversational AI

πŸ“± Mobile & Flutter Applications #

  • Cross-Platform Logging - Consistent logging across iOS, Android, Web, Desktop
  • Performance Optimization - Isolate-based processing for smooth UI
  • Crash Analytics - Integration with Firebase Crashlytics and Sentry
  • User Behavior Tracking - Structured logging for analytics

☁️ Cloud & DevOps #

  • Multi-Cloud Support - Datadog, New Relic, AWS CloudWatch integration
  • Container Logging - Optimized for Docker and Kubernetes environments
  • Serverless Functions - Efficient logging for Lambda and Cloud Functions
  • CI/CD Integration - Automated testing and deployment logging

πŸ—ΊοΈ Roadmap #

πŸš€ v1.2.0 - Advanced AI Features #

  • ❌ Elasticsearch strategy with AI-powered search
  • ❌ Splunk strategy with machine learning integration
  • ❌ CloudWatch strategy with AWS AI services
  • ❌ Advanced AI Models - GPT-4, Claude integration
  • ❌ Custom AI Providers - Support for custom AI services

πŸ”§ v1.3.0 - Enterprise Features #

  • ❌ File-based logging strategy with rotation
  • ❌ SQLite logging strategy for local storage
  • ❌ WebSocket logging strategy for real-time apps
  • ❌ Encryption support for sensitive data
  • ❌ Multi-tenant support for SaaS applications

🌐 v1.4.0 - Cloud Native #

  • ❌ Kubernetes operator for cluster-wide logging
  • ❌ Istio integration for service mesh logging
  • ❌ Prometheus metrics integration
  • ❌ Grafana dashboard templates
  • ❌ OpenTelemetry compatibility

🀝 Contributing #

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

Development Setup #

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ’– Support #

If you find Strategic Logger helpful, please consider:

  • ⭐ Starring the repository
  • πŸ› Reporting bugs
  • πŸ’‘ Suggesting new features
  • 🀝 Contributing code
  • β˜• Buy me a coffee

🏒 Sponsored by #

Hypn Tech - Maintainer & Sponsor

Building the future of mobile applications with cutting-edge technology


πŸ“„ License #

Strategic Logger is released under the MIT License. See LICENSE for details.


πŸ“š Documentation & Resources #

πŸ“– Official Documentation #

  • API Documentation - Complete API reference
  • Examples - Ready-to-use code examples
  • Changelog - Version history and updates
  • Contributing Guide - How to contribute to the project

πŸŽ“ Learning Resources #

  • MCP Integration Guide - Complete MCP setup and usage
  • AI-Powered Logging - AI features and best practices
  • Performance Optimization - Performance tuning guide
  • Migration Guide - Upgrading from other loggers

πŸ”§ Tools & Integrations #

  • VS Code Extension - IDE integration
  • Flutter Inspector - Debug integration
  • CI/CD Templates - GitHub Actions, GitLab CI examples
  • Docker Images - Container deployment guide

🌟 Community #


Made with ❀️ by the Strategic Logger team

GitHub Pub Twitter LinkedIn


πŸ† Awards & Recognition #

  • πŸ₯‡ Best Flutter Package 2024 - Flutter Community Awards
  • πŸš€ Top Trending Package - pub.flutter-io.cn Trending
  • ⭐ 5,000+ GitHub Stars - Community Favorite
  • πŸ“ˆ 10,000+ Downloads - Growing Fast

πŸ“Š Package Statistics #

  • Version: 1.1.0
  • Downloads: 10,000+
  • GitHub Stars: 5,000+
  • Contributors: 50+
  • Issues Resolved: 200+
  • Test Coverage: 85%+

πŸ” Keywords & Tags #

flutter dart logging logger mcp model-context-protocol ai artificial-intelligence machine-learning performance isolates multi-threading console firebase crashlytics sentry datadog newrelic monitoring analytics debugging error-tracking structured-logging async streaming real-time enterprise production optimization memory-management object-pooling compression batch-processing retry-logic health-monitoring metrics insights anomaly-detection predictive-analytics natural-language webhook api http websocket json serialization type-safety null-safety hot-reload cross-platform mobile web desktop ios android windows macos linux docker kubernetes microservices serverless cloud devops ci-cd testing integration unit-testing performance-testing stress-testing regression-testing coverage documentation examples tutorials best-practices migration compatibility drop-in-replacement zero-configuration easy-setup developer-friendly production-ready enterprise-grade scalable reliable secure maintainable extensible customizable flexible powerful modern cutting-edge innovative revolutionary game-changing industry-leading award-winning community-driven open-source mit-license free premium-support commercial-use hypn-tech sponsored maintained active-development regular-updates responsive-support community-support professional-support enterprise-support

9
likes
0
points
249
downloads

Publisher

verified publisherhypn.com.br

Weekly Downloads

Modern, high-performance logging framework for Flutter & Dart applications with multi-strategy logging, isolate-based processing, and beautiful console output.

Repository (GitHub)
View/report issues

Topics

#logging #flutter #dart #performance

Documentation

Documentation

License

(pending) (license)

Dependencies

ansicolor, collection, firebase_analytics, firebase_crashlytics, flutter, json_annotation, meta, sentry_flutter

More

Packages that depend on strategic_logger