Snug Logger 🛋️
A colorful, structured logger for Flutter apps.
Snug Logger helps you:
- read logs faster with clean formatting and colors
- log by intent (
debug,info,error,production) - inspect Dio network traffic with optional cURL output
- get readable stack traces for error debugging
Install
dependencies:
snug_logger: ^1.0.11
flutter pub get
Quick Start
import 'package:snug_logger/snug_logger.dart';
snugLog('App started', logType: LogType.info);
snugLog('Fetching user profile', logType: LogType.debug);
Error Logging with Stack Trace
try {
throw Exception('Something went wrong');
} catch (error, stackTrace) {
snugLog(
error,
logType: LogType.error,
stackTrace: stackTrace,
);
}
Network Logging (Dio)
_dio.interceptors.add(
SnugDioLogger(
requestHeaders: true,
requestData: true,
responseHeaders: true,
responseData: true,
showCurl: true,
logPrint: (object) => debugPrint(object.toString()),
),
);
When showCurl: true is enabled, Snug Logger prints reproducible cURL commands so you can quickly share failing requests with backend teams.
What You Can Configure
requestHeaders: include request headersrequestData: include request body/queryresponseHeaders: include response headersresponseData: include response bodyshowCurl: print cURL command for each request
Advanced Stack Trace Utilities
If you want direct control over stack trace formatting:
final formatted = StackTraceFormatter.format(stackTrace);
final terse = StackTraceFormatter.formatTerse(stackTrace);
final snug = StackTraceFormatter.formatForSnugLogger(stackTrace);
Contributing
Thanks to Contributors
Thanks to everyone who contributed features, fixes, docs, and reviews, including the cURL printing enhancement.
Contributor Wall
Libraries
- snug_logger
- A cozy and efficient logging package for Flutter applications.