offline_logger 0.0.1 copy "offline_logger: ^0.0.1" to clipboard
offline_logger: ^0.0.1 copied to clipboard

Offline-first logging and crash reporting SDK for Flutter apps

๐Ÿ“ฆ Offline Logger SDK โ€“ Enterprise Documentation #

๐Ÿš€ Overview #

Offline Logger is a production-grade, offline-first observability SDK for Flutter applications.

It enables:

  • Reliable logging in low/no internet environments
  • Crash tracking and debugging
  • Automatic batching and syncing
  • Scalable observability for large deployments

๐Ÿงฑ Architecture #

App Layer
   โ†“
OfflineLogger SDK
   โ†“
Hive Storage (Local DB)
   โ†“
Sync Engine (Retry + Batch)
   โ†“
Backend API

โš™๏ธ Initialization #

init(LoggerConfig config) #

Purpose #

Initializes entire SDK system.

Responsibilities #

  • Initializes Hive
  • Creates SyncService
  • Generates sessionId
  • Fetches device info
  • Starts heartbeat
  • Sets lifecycle + connectivity listeners
  • Flushes pre-init logs

Usage #

await OfflineLogger.init(
  LoggerConfig(
    apiEndpoint: "https://api.yourserver.com/logs",
    enableDebugLogs: true,
  ),
);

๐Ÿง  Logging APIs #

log() #

General logging

OfflineLogger.log("User clicked button");

error() #

Recoverable errors

OfflineLogger.error("API failed");

crash() #

Critical crash logging

OfflineLogger.crash(error, stack);

๐Ÿท๏ธ Tagged Logging #

logWithTag() #

OfflineLogger.logWithTag("VIDEO", "Playback started");

errorWithTag() #

OfflineLogger.errorWithTag("API", "Login failed");

๐Ÿงพ Metadata #

setGlobalMetadata() #

Adds metadata to all logs

OfflineLogger.setGlobalMetadata({
  "userId": "123",
  "schoolId": "UP_1023",
});

restartSession() #

Creates new session

OfflineLogger.restartSession();

๐Ÿ”„ Sync System #

sync() #

Triggers log upload

Features #

  • Batch processing
  • Retry with backoff
  • Timeout protection
  • Sync locking

safeSync() #

Safe wrapper

await OfflineLogger.safeSync();

flush() #

Force upload logs

await OfflineLogger.flush();

๐Ÿ“ค Data Access #

exportLogs() #

final logs = await OfflineLogger.exportLogs();

๐Ÿงน Cleanup #

dispose() #

await OfflineLogger.dispose();

๐Ÿ“ฑ Crash Handling #

runAppWithLogger() #

Wrap app

OfflineLogger.runAppWithLogger(() {
  runApp(MyApp());
});

๐Ÿ” Internal Mechanisms #

Pre-init Queue #

  • Stores logs before init
  • Max size: 100
  • Auto flushed

Sync Engine #

  • Batching
  • Retry
  • Timeout (15s)

Connectivity #

  • Debounced sync trigger

Heartbeat #

  • Runs every 5 min

๐Ÿ“ฆ Log Structure #

{
  "id": "uuid",
  "type": "info",
  "message": "...",
  "priority": "low",
  "metadata": {},
  "timestamp": "ISO",
  "isSynced": false
}

๐Ÿ“Š Captured Data #

Automatic #

  • Flutter errors
  • Unhandled exceptions
  • Lifecycle events
  • Connectivity changes

Manual #

  • User actions
  • API failures
  • Business logic

โš ๏ธ Limitations #

  • No native crash capture
  • No ANR detection
  • No performance monitoring

๐Ÿง  Best Practices #

Do #

  • Log meaningful events
  • Use metadata
  • Use tagging

Avoid #

  • Sensitive data
  • Large payloads
  • Over-logging

๐Ÿš€ Production Readiness #

โœ” Offline-first
โœ” Retry + batching
โœ” Scalable
โœ” Memory-safe
โœ” No log loss


๐Ÿ“Œ Summary #

Offline Logger provides a complete observability layer for Flutter apps, optimized for low-connectivity environments and large-scale deployments.

2
likes
130
points
90
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Offline-first logging and crash reporting SDK for Flutter apps

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

archive, connectivity_plus, device_info_plus, dio, flutter, hive, hive_flutter, package_info_plus, uuid

More

Packages that depend on offline_logger