flutter_awesome_logger 1.1.0 copy "flutter_awesome_logger: ^1.1.0" to clipboard
flutter_awesome_logger: ^1.1.0 copied to clipboard

Awesome debugging with floating logger, automatic API logging (using interceptor), and a beautiful UI for viewing logs.

Flutter Awesome Logger πŸš€ #

A comprehensive Flutter logging package that makes debugging a breeze!

pub package License Flutter Dart

Features a floating logger, automatic API logging with Dio interceptor, and a beautiful UI for viewing logs.

πŸ“– Documentation β€’ πŸš€ Installation β€’ πŸ’‘ Examples β€’ 🎨 Customization

πŸ“‹ Table of Contents #

Click to expand

✨ Features #

Feature Description
πŸ“± Floating Logger Button Always accessible debug button that floats over your app - drag to reposition, auto-snaps to edges
πŸ‘† Long Press Floating Button Tap: Opens logger UI instantly β€’ Long Press: Shows quick actions menu β€’ Drag: Repositions button β€’ Double Tap: Toggles pause/resume logging
🀳 Shake to Toggle Shake your device to show/hide the floating logger button - perfect for quick access during testing
🀳 Shake to Enable Shake your device to enable the logger when disabled - ideal for production builds with hidden debug access
🌐 Automatic API Logging Built-in Dio interceptor for seamless API logging - captures requests, responses, errors, and timing automatically
🎨 Beautiful UI Clean, modern interface with syntax highlighting - dark/light themes, collapsible sections, and intuitive navigation
πŸ“Š Multiple Log Levels Support for debug, info, warning, error, and verbose logs - color-coded with filtering and search capabilities
πŸ’Ύ Smart Storage Logs stored only when logger is enabled - conserves memory and respects privacy settings
⏸️ Pause/Resume Logging Temporarily pause all logging with visual indicators - useful for focusing on specific app sections
πŸ” Search & Filter Easily find specific logs with advanced filtering - search by text, level, timestamp, or source file
🎯 Simple Configuration Single enabled property controls both UI and storage - async support for conditional initialization
πŸ“± Responsive Design Works perfectly on all screen sizes - adaptive layouts for phones, tablets, and different orientations

πŸ“Έ Screenshots #

Floating Logger Button

🎯 Floating Logger Button
Always accessible debug interface
API Logs View

🌐 API Logs View
Comprehensive API request/response logging

General Logs View

πŸ“Š General Logs View
Beautiful log interface with filtering
Log Details

πŸ” Log Details
Detailed log inspection with syntax highlighting

πŸš€ Getting Started #

Installation #

πŸ“¦ Add to your pubspec.yaml

dependencies:
  flutter_awesome_logger: ^latest_version

πŸ”„ Install the package

# Using Flutter CLI
flutter pub get

# Or using Dart CLI
dart pub get

πŸ“± Import in your Dart code

import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

Basic Usage #

🎯 Choose Your Setup Method

⚑ Easiest Setup

(Just 2 Lines!)

Wrap your app - that's it!

πŸš€ Auto-Configuration

(Recommended)

With custom configuration

βš™οΈ Manual Setup

(Advanced Control)

Full manual control


⚑ Easiest Setup (Just 2 Lines!)

The absolute simplest way to get started - just wrap your app:

import 'package:flutter/material.dart';
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FlutterAwesomeLogger(
        child: YourHomePage(), // Your existing home page
      ),
    );
  }
}

That's it! πŸŽ‰ The logger is now active with default settings. You'll see:

  • πŸ“± Floating logger button on your screen
  • 🀳 Shake-to-toggle functionality enabled
  • πŸ“Š Both API logs and general logs tabs ready

πŸ“‹ How to Get Logs in Each Tab #

🌐 API Logs Tab #

For HTTP requests and responses

To populate the API Logs tab with your HTTP requests, add the Dio interceptor:

Step 1: Add the interceptor to your Dio instance

import 'package:dio/dio.dart';
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

final dio = Dio();
dio.interceptors.add(FlutterAwesomeLoggerDioInterceptor());

// Now all API calls are automatically logged!
final response = await dio.get('https://api.example.com/data');

What you get:

  • βœ… Automatic capture - All requests and responses logged automatically
  • βœ… cURL generation - Copy-paste ready cURL commands for testing
  • βœ… Error handling - Network errors and HTTP errors captured
  • βœ… Performance timing - Request duration tracking
  • βœ… Advanced filtering - Filter by status code, method, or endpoint
  • βœ… Search functionality - Search through URLs, headers, and response content

πŸ“Š General Logs Tab #

For application logs and debugging

To populate the General Logs tab with your application logs:

Step 1: Create a logger instance // Create global logger instance (recommended: make a new file eg. my_logger.dart)

import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

final logger = FlutterAwesomeLogger.loggingUsingLogger;

Step 2: Use the logger throughout your app

import 'my_logger.dart';

class MyService {
  void performOperation() {
    // Debug information (development only)
    logger.d('Starting complex operation with parameters: $params');
    
    // General information (important events)
    logger.i('User logged in successfully');
    
    // Warnings (potential issues)
    logger.w('API rate limit approaching: ${remaining} requests left');
    
    // Errors (with full context)
    try {
      // Your code here
    } catch (e, stackTrace) {
      logger.e('Failed to process user data', error: e, stackTrace: stackTrace);
    }
  }
}

What you get:

  • βœ… Multiple log levels - DEBUG (grey), INFO (blue), WARNING (orange), ERROR (red)
  • βœ… Stack trace support - Full error context with file paths and line numbers
  • βœ… Source tracking - See exactly which file and method generated each log
  • βœ… Advanced filtering - Filter by log level, source file, or search content
  • βœ… Export capabilities - Copy individual logs or export entire filtered sets
  • βœ… Real-time updates - Logs appear instantly as your app runs

For more control over settings, use auto-configuration:

import 'package:flutter/material.dart';
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create global logger instance using FlutterAwesomeLogger
final logger = FlutterAwesomeLogger.loggingUsingLogger;

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  // Example: Enable logger after checking some condition
  Future<bool> _shouldEnableLogger() async {
    // Check if we're in debug mode, user preferences, etc.
    await Future.delayed(const Duration(seconds: 2)); // Simulate async check
    return true; // Or false based on your logic
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FlutterAwesomeLogger(
        enabled: _shouldEnableLogger(), // Can be Future<bool> or bool
        // Auto-configure logger settings
        loggerConfig: const AwesomeLoggerConfig(
          maxLogEntries: 500,
          showFilePaths: true,
          showEmojis: true,
          useColors: true,
        ),
        // Floating logger UI configuration
        config: const FloatingLoggerConfig(
          backgroundColor: Colors.deepPurple,
          icon: Icons.developer_mode,
          showCount: true,
          enableGestures: true,
          autoSnapToEdges: true,
        ),
        child: const YourHomePage(),
      ),
    );
  }
}

Option 2: Manual Configuration (Advanced)

For more control, configure manually in main(). Note: Manual configuration doesn't automatically control log storage - use Option 1 for simpler setup.

import 'package:flutter/material.dart';
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create global logger instance using FlutterAwesomeLogger
final logger = FlutterAwesomeLogger.loggingUsingLogger;

void main() {
  // Manual configuration
  LoggingUsingLogger.configure(
    const AwesomeLoggerConfig(
      maxLogEntries: 500,
      showFilePaths: true,
      showEmojis: true,
      useColors: true,
    ),
  );

  // Manual initialization
  FloatingLoggerManager.initialize();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FlutterAwesomeLogger(
        enabled: true, // Controls both floating logger AND log storage
        // Don't auto-configure since we did it manually
        config: const FloatingLoggerConfig(
          backgroundColor: Colors.deepPurple,
          icon: Icons.developer_mode,
          showCount: true,
          enableGestures: true,
          autoSnapToEdges: true,
        ),
        child: const YourHomePage(),
      ),
    );
  }
}
  1. Start logging:
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create global logger instance using FlutterAwesomeLogger
final logger = FlutterAwesomeLogger.loggingUsingLogger;

// Use the logger instance anywhere in your app
logger.d('Debug message');
logger.i('Info message');
logger.w('Warning message');
logger.e('Error message');

API Logging with Dio #

🌐 Automatic API Logging Setup

After setting up the basic logger (see Easiest Setup above), add API logging:

import 'package:dio/dio.dart';
import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create your Dio instance
final dio = Dio();

// Add the awesome logger interceptor - that's it!
dio.interceptors.add(FlutterAwesomeLoggerDioInterceptor());

// Now all your API calls are automatically logged in the API Logs tab!
final response = await dio.get('https://api.example.com/data');
final postResponse = await dio.post('https://api.example.com/users', data: {'name': 'John'});

πŸ“Š What You Get in API Logs Tab

πŸ“ˆ Statistics

  • Total requests
  • Success count
  • Error count
  • Average response time

πŸ” Filtering

  • By HTTP method (GET, POST, etc.)
  • By status code (2xx, 4xx, 5xx)
  • By endpoint
  • Search in URL/content

πŸ“‹ Request Details

  • Full request headers
  • Request body/parameters
  • cURL command generation
  • Timestamp and duration

πŸ“₯ Response Details

  • Response headers
  • Response body (formatted JSON)
  • Status codes and errors
  • Copy/export functionality

πŸ’‘ Pro Tip: The interceptor automatically handles all HTTP methods (GET, POST, PUT, DELETE, PATCH) and captures both successful responses and errors!

General Application Logging #

πŸ“Š Application Logs Setup

After setting up the basic logger (see Easiest Setup above), start logging in your app:

import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create global logger instance (do this once, usually in main.dart)
final logger = FlutterAwesomeLogger.loggingUsingLogger;

// Use anywhere in your app
class MyService {
  void performOperation() {
    logger.d('Starting operation...'); // Debug
    
    try {
      // Your business logic
      final result = someComplexOperation();
      logger.i('Operation completed successfully: $result'); // Info
      
    } catch (e, stackTrace) {
      logger.e('Operation failed', error: e, stackTrace: stackTrace); // Error with stack trace
    }
  }
  
  void validateInput(String input) {
    if (input.isEmpty) {
      logger.w('Empty input received - using default value'); // Warning
    }
  }
}

πŸ“‹ What You Get in General Logs Tab

🎯 Log Levels

  • DEBUG (grey) - Development info
  • INFO (blue) - General information
  • WARNING (orange) - Potential issues
  • ERROR (red) - Actual problems

πŸ” Advanced Filtering

  • Filter by log level
  • Filter by source file/class
  • Search in messages
  • Sort by newest/oldest

πŸ“ Source Tracking

  • File path where log originated
  • Class/method information
  • Timestamp for each log
  • Stack trace for errors

πŸ“€ Export Options

  • Copy individual messages
  • Copy full log details
  • Copy stack traces
  • Export filtered logs

πŸ’‘ Pro Tips:

  • Use logger.d() for debugging information during development
  • Use logger.i() for important app events (user actions, state changes)
  • Use logger.w() for recoverable issues that need attention
  • Use logger.e() for actual errors, always include error and stackTrace parameters

πŸ”§ Configuration Options #

βš™οΈ Flexible Configuration System #

πŸŽ›οΈ FlutterAwesomeLogger Configuration

The enabled parameter supports both synchronous and asynchronous initialization:

🟒 Immediate Enable

enabled: true

Logger starts immediately

πŸ”΄ Immediate Disable

enabled: false

Logger is disabled

⏳ Async Enable

enabled: someFuture()

Waits for Future resolution


πŸ“Š AwesomeLoggerConfig

Core logging behavior configuration

Property Type Default Description
maxLogEntries int 1000 Maximum number of log entries to keep in memory
showFilePaths bool true Display file paths in console output
showEmojis bool true Show emojis in console output for better readability
useColors bool true Enable colored console output
stackTraceLines int 0 Number of stack trace lines to display
const AwesomeLoggerConfig({
  int maxLogEntries = 1000,
  bool showFilePaths = true,
  bool showEmojis = true,
  bool useColors = true,
  int stackTraceLines = 0,
});

🎨 FloatingLoggerConfig

Floating button UI and behavior configuration

Property Type Default Description
backgroundColor Color Colors.deepPurple Background color of the floating button
icon IconData Icons.developer_mode Icon displayed on the floating button
showCount bool true Display log count badge on button
enableGestures bool true Enable drag gestures for repositioning
autoSnapToEdges bool true Automatically snap button to screen edges
size double 60.0 Size of the floating button
enableShakeToShowHideFloatingButton bool true Enable shake-to-toggle button visibility
enableShakeToEnableLogger bool true Enable shake-to-enable logger when disabled
shakeSensitivity int 8 Shake sensitivity (1-15, higher = less sensitive)
const FloatingLoggerConfig({
  Color backgroundColor = Colors.deepPurple,
  IconData icon = Icons.developer_mode,
  bool showCount = true,
  bool enableGestures = true,
  bool autoSnapToEdges = true,
  double size = 60.0,
  bool enableShakeToShowHideFloatingButton = true,
  bool enableShakeToEnableLogger = true,
  int shakeSensitivity = 8,
});

πŸ“š Advanced Usage #

Logger Factory Pattern #

The package now uses a clean factory pattern for accessing the logger:

import 'package:flutter_awesome_logger/flutter_awesome_logger.dart';

// Create global logger instance (recommended approach)
final logger = FlutterAwesomeLogger.loggingUsingLogger;

// Use anywhere in your app without additional imports
class MyService {
  void doSomething() {
    logger.d('Debug message from service');
    logger.i('Info: Operation completed');
    
    try {
      // Some operation
    } catch (e, stackTrace) {
      logger.e('Error in service', error: e, stackTrace: stackTrace);
    }
  }
}

Accessing Log History #

// Get all stored logs
final logs = FlutterAwesomeLogger.getLogs();

// Get logs by level
final errorLogs = FlutterAwesomeLogger.getLogsByLevel('ERROR');

// Get recent logs
final recentLogs = FlutterAwesomeLogger.getRecentLogs(
  duration: Duration(minutes: 10),
);

// Clear all logs
FlutterAwesomeLogger.clearLogs();

// Export logs as formatted text
String exportedLogs = FlutterAwesomeLogger.exportLogs();

Programmatically Show Logger UI #

// Show the logger history page
Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => const LoggerHistoryPage(),
  ),
);

Pause/Resume Logging #

// Pause all logging (both console and storage)
FlutterAwesomeLogger.setPauseLogging(true);

// Resume logging
FlutterAwesomeLogger.setPauseLogging(false);

// Check if logging is paused
bool isPaused = FlutterAwesomeLogger.isPaused;

Control Floating Logger Visibility #

// Check if floating logger is visible
bool isVisible = FlutterAwesomeLogger.isVisible();

// Show/hide the floating logger
FlutterAwesomeLogger.setVisible(true);  // Show
FlutterAwesomeLogger.setVisible(false); // Hide

// Toggle visibility
FlutterAwesomeLogger.toggleVisibility();

Manage API Logs #

// Get all API logs
final apiLogs = FlutterAwesomeLogger.getApiLogs();

// Get API logs by type
final successLogs = FlutterAwesomeLogger.getApiLogsByType(ApiLogType.success);
final errorLogs = FlutterAwesomeLogger.getApiLogsByType(ApiLogType.serverError);

// Clear API logs
FlutterAwesomeLogger.clearApiLogs();

🎨 Customization #

The logger UI is highly customizable. You can:

  • Change colors and themes
  • Customize the floating button appearance
  • Configure log display formats
  • Add custom filters and search options
  • Pause/resume logging as needed
  • Control logging behavior with simple configuration
  • Enable/disable shake-to-toggle functionality
  • Enable/disable shake-to-enable functionality for production builds
  • Adjust shake sensitivity for different devices

🀝 Contributing #

We welcome contributions!

Contributors Pull Requests

Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

πŸ”§ Contribute β€’ πŸ“‹ Issues β€’ πŸ’‘ Feature Requests


πŸ“ License #

License: MIT

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


πŸ› Issues & Support #

πŸ› Bug Reports #

Found a bug? Let us know!

Issues

Report Bug

πŸ’‘ Feature Requests #

Have an idea? Share it!

Feature Requests

Request Feature

πŸ’¬ Discussions #

Join the conversation!

Discussions

Start Discussion


πŸ“ž Connect With Us #

πŸ“§ Email #

[email protected]

🐦 Twitter #

@codeastartup01dev

πŸ’¬ Discord #

Join our community


⭐ Show Your Support #

If this package helped you, please consider giving it a ⭐ on GitHub!

GitHub stars GitHub forks


Made with ❀️ by codeastartup01dev

3
likes
0
points
68
downloads

Publisher

unverified uploader

Weekly Downloads

Awesome debugging with floating logger, automatic API logging (using interceptor), and a beautiful UI for viewing logs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, logger, path, shake

More

Packages that depend on flutter_awesome_logger