LogKit πŸ“œπŸš€

Pub Version License Flutter Compatible Platforms

LogKit is a lightweight, powerful, and production-ready Flutter logging package that extends the popular logger package.
It supports console logging, Hive-based persistent storage, and log exportingβ€”on both native and web platforms.


🌟 Features

βœ… Console Logging with the logger package
βœ… Persistent Log Storage using Hive (Filesystem on native, IndexedDB on Web)
βœ… Auto-delete logs from previous day to prevent bloat
βœ… Export logs to a .log file (native) or download as .log (web)
βœ… Supports all major log levels: debug, info, warning, error, fatal
βœ… Compatible with Android, iOS, Windows, macOS, Linux, and Web (WASM)


πŸ› οΈ Getting Started

1️⃣ Add Dependency

In your pubspec.yaml:

dependencies:
  logkit: ^1.0.0  # Use the latest version
  hive: ^2.2.3
  path_provider: ^2.1.5

Then run:

flutter pub get

πŸ“Œ Usage

πŸ”Ή Import LogKit

import 'package:logkit/logkit.dart';

πŸ”Ή Initialize Logger

Call initialize() before logging anything:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final logger = UISLogger();
  await logger.initialize(); // Required for Hive setup
  runApp(const MyApp());
}

πŸ”Ή Log Messages

logger.log("This is an info message");  // Default level: info

logger.log("Debugging details...", level: Level.debug);
logger.log("Warning message!", level: Level.warning);
logger.log("Something went wrong!", level: Level.error);

πŸ”Ή Export Logs

πŸ–₯️ On native platforms:

String path = await logger.exportLogsToFile();
print("Logs exported to: $path");

🌐 On web:

await logger.exportLogsToWebDownload(); // Triggers browser download

πŸ”Ή Get All Logs

List<String> logs = logger.getAllLogs();
logs.forEach(print);

🎯 Example App

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final logger = UISLogger();
  await logger.initialize();
  logger.log("App started!");

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("LogKit Example")),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              final logger = UISLogger();
              logger.log("Button clicked!", level: Level.info);
            },
            child: const Text("Log Message"),
          ),
        ),
      ),
    );
  }
}

πŸ“‚ Log Storage Details

Platform Storage Mechanism Export Support
Android / iOS Hive in app document dir Yes – via File
Windows / macOS / Linux Hive in user directory Yes – via File
Web (WASM) Hive in IndexedDB Yes – via browser download

🀝 Contributing

We welcome contributions!

  • βœ… Report bugs via GitHub issues
  • βœ… Submit PRs for improvements
  • βœ… Help us improve support for new platforms or features

πŸ“ License

This project is licensed under the MIT License. See LICENSE for full details.


πŸš€ Start logging like a pro with LogKit! πŸ”₯ Lightweight. Flexible. Cross-platform.

Libraries

logkit