0 purchases
smart logs
Smart Log
Introducing a sleek Flutter package designed to streamline user event logging and exception reporting. With this package, users can easily submit bug reports to developers via a user-friendly dialog. Developers can specify their email address, simplifying the process of receiving vital bug reports.
Table of contents #
Installing
Android
Usage
Smart log report dialog
Dialog
SLog Report Dialog All Parameters
Bugs or Requests
Installing #
1. Depend on it #
Add this to your package's pubspec.yaml file:
dependencies:
smart_logs: ^1.0.1
copied to clipboard
2. Install it #
You can install packages from the command line:
with pub:
$ pub get
copied to clipboard
with Flutter:
$ flutter pub get
copied to clipboard
3. Import it #
Now in your Dart code, you can use:
import 'package:smart_logs/smart_logs.dart';
copied to clipboard
Android Setup #
With Android 11, package visibility is introduced that alters the ability to query installed applications and packages on a user’s device. To enable your application to get visibility into the packages you will need to add a list of queries into your AndroidManifest.xml.
Note To utilize the report dialog with default report button settings on Android, you are required to perform some configuration steps. Here are the necessary instructions:
<manifest package="com.mycompany.myapp">
<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>
</manifest>
copied to clipboard
Usage #
Smart Log This package offers a range of methods for various functionalities. However, to ensure smooth operation, it's crucial to initialize it first. You can initialize it from anywhere in your app, but it's advisable to call the initialize method in the main function for optimal performance. like:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Slog.initializeSLog();
// Your Code
}
copied to clipboard
It has many configurable properties (Optional), including:
forceFullyDelete – to delete everything related to logs. like zip, json and .log files
daysToDeleteLog – To remove logs created before a specified date, this parameter is set to delete logs older than 7 days by default.
logFolderName – to designate the name of your log file folder or directory...
logZipFileName – to designate the name of your log zip file.
jsonFileName – to designate the name of your json file.
There are also custom setter's, getter's, callbacks:
setForceFullyDelete(bool value) – When set to true, this setter will forcibly delete all data related to logs.
setZipPassword(String value) – This setter method allows you to add a password to zip file created.
getLogFileAsText – This getter returns the current log file content as a string.
summaryLog({ String tag = "Message", required String text, bool shouldSave = true, dynamic exception,dynamic stackTrace,} – This method adds your log message to the log file. The exception parameter is optional and can be used to include an exception in the log message.
getLogAsZip() - This callback creates a zip file of the log files and returns the path to the zip file.
Note:
You might encounter a NotInitializationException if you call an instance of SLog directly. When the initialize method is called, it takes some time for initialization. It is recommended to await the initialization method to ensure that the necessary setup is completed before using SLog instances.
// Adding log
Slog.instance.summaryLog(text:'your message');
// Log with exception
Slog.instance.summaryLog(text:'your message', exception:YourException());
copied to clipboard
// Getting File content as String
Slog.instance.getLogFileAsText;
// Log with exception
Slog.instance.summaryLog(text:'your message', exception:YourException(),stackTrace:StackTrace() );
copied to clipboard
Smart log report dialog #
Smart Report Dialog is a part of Smart log Flutter package that streamlines the process of collecting user bug reports. Users can enter their bug report messages, and when they tap the send button, they are redirected to their email app with a pre-configured email. The email includes two default attachments: a zipped log file and a deviceinfo.json file containing device information. This dialog is highly customizable, allowing you to modify the title, hintText, buttonTitle, buttonStyle, and the dialog's background. You can also customize the send button callback to provide your own functionality. This package simplifies the bug reporting process, enhancing the user experience.
Dialog #
SLDialog.SL_DIALOG(
context,
sendToEmail: '[email protected]',
emailsubject: 'Example Bug by user',
);
copied to clipboard
Note: These 3 parameter is required. In which one is positional and two are named parameter
SLog Report Dialog All Parameters #
SL_DIALOG(
BuildContext context, {
required String emailsubject,
required String sendToEmail,
bool dialogBarrierDismissible = false,
ButtonStyle? reportButtonStyle,
BoxDecoration? topContainerDecoration,
Color? dialogBackgroundColor,
Color? emailBodyTextFieldBackgrounColor,
Color dialogBarrierColor = Colors.black38,
Color? lineColor,
Color? cursorColor,
Color toastBackGround = Colors.black,
Color toastTextColor = Colors.white,
double dialogElevation = 0,
double dialogWithOpacity = .5,
double toastFontSize = 15,
EdgeInsetsGeometry? dialogWidgetsPadding,
Function()? reportButtonPress,
Widget? reportButtonIcon,
int maxEmailBodyTextFieldLines = 10,
int maxEmailBodyCharacterLength = 4000,
int minimumEmailBodyLength = 10,
String hintText = 'Write here about your bug detail',
String? minmumToastText,
ToastGravity toastGravity = ToastGravity.BOTTOM,
List<String>? sendToEmails,
List<String>? cc,
List<String>? bcc,
TextStyle? emailBodyTextStyle,
TextStyle? hintTextStyle,
Widget? reportButtonTitle,
Widget? divider,
Widget? reportTitle,
TextStyle? textFieldTextStyle,
})
copied to clipboard
Bugs or Requests #
If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.