Skip to content

Commit

Permalink
Fixes #28, async functions should return Future + format
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCsabaToth committed Jun 23, 2022
1 parent 3b9fb4e commit 71b95f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main() {
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data!.startsWith('Running on:'),
(Widget widget) =>
widget is Text && widget.data!.startsWith('Running on:'),
),
findsOneWidget,
);
Expand Down
33 changes: 21 additions & 12 deletions lib/flutter_logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import 'dart:async';
import 'package:flutter/services.dart';

enum DirectoryStructure { FOR_DATE, FOR_EVENT, SINGLE_FILE_FOR_DAY }

enum LogFileExtension { TXT, CSV, LOG, NONE }

enum LogLevel { INFO, WARNING, ERROR, SEVERE }

enum LogType {
Device,
Location,
Expand All @@ -16,6 +19,7 @@ enum LogType {
Jobs,
Errors
}

enum TimeStampFormat {
DATE_FORMAT_1,
DATE_FORMAT_2,
Expand All @@ -27,6 +31,7 @@ enum TimeStampFormat {
TIME_FORMAT_READABLE_2,
TIME_FORMAT_SIMPLE
}

enum ExportType { TODAY, LAST_HOUR, WEEKS, LAST_24_HOURS, ALL }

class FlutterLogs {
Expand Down Expand Up @@ -185,7 +190,7 @@ class FlutterLogs {
});
}

static void logThis(
static Future<void> logThis(
{String tag = "",
String subTag = "",
String logMessage = "",
Expand Down Expand Up @@ -234,7 +239,8 @@ class FlutterLogs {
}
}

static void logInfo(String tag, String subTag, String logMessage) async {
static Future<void> logInfo(
String tag, String subTag, String logMessage) async {
final String result =
await channel.invokeMethod('logThis', <String, dynamic>{
'tag': tag,
Expand All @@ -245,7 +251,8 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void logWarn(String tag, String subTag, String logMessage) async {
static Future<void> logWarn(
String tag, String subTag, String logMessage) async {
final String result =
await channel.invokeMethod('logThis', <String, dynamic>{
'tag': tag,
Expand All @@ -256,7 +263,8 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void logError(String tag, String subTag, String logMessage) async {
static Future<void> logError(
String tag, String subTag, String logMessage) async {
final String result =
await channel.invokeMethod('logThis', <String, dynamic>{
'tag': tag,
Expand All @@ -267,7 +275,7 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void logErrorTrace(
static Future<void> logErrorTrace(
String tag, String subTag, String logMessage, Error e) async {
final String result =
await channel.invokeMethod('logThis', <String, dynamic>{
Expand All @@ -280,7 +288,7 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void logToFile(
static Future<void> logToFile(
{String logFileName = "",
bool overwrite = false,
String logMessage = "",
Expand All @@ -299,7 +307,7 @@ class FlutterLogs {
}
}

static void exportLogs(
static Future<void> exportLogs(
{ExportType exportType = ExportType.ALL,
bool decryptBeforeExporting = false}) async {
final String result =
Expand All @@ -310,7 +318,7 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void printLogs(
static Future<void> printLogs(
{ExportType exportType = ExportType.ALL,
bool decryptBeforeExporting = false}) async {
final String result =
Expand All @@ -321,7 +329,7 @@ class FlutterLogs {
printDebugMessage(result, 2);
}

static void exportFileLogForName(
static Future<void> exportFileLogForName(
{String logFileName = "", bool decryptBeforeExporting = false}) async {
if (logFileName.isNotEmpty) {
final String result = await channel.invokeMethod(
Expand All @@ -335,13 +343,14 @@ class FlutterLogs {
}
}

static void exportAllFileLogs({bool decryptBeforeExporting = false}) async {
static Future<void> exportAllFileLogs(
{bool decryptBeforeExporting = false}) async {
final String result = await channel.invokeMethod('exportAllFileLogs',
<String, dynamic>{'decryptBeforeExporting': decryptBeforeExporting});
printDebugMessage(result, 2);
}

static void printFileLogForName(
static Future<void> printFileLogForName(
{String logFileName = "", bool decryptBeforeExporting = false}) async {
if (logFileName.isNotEmpty) {
final String result = await channel.invokeMethod(
Expand All @@ -355,7 +364,7 @@ class FlutterLogs {
}
}

static void clearLogs() async {
static Future<void> clearLogs() async {
final String result = await channel.invokeMethod('clearLogs');
printDebugMessage(result, 2);
}
Expand Down

0 comments on commit 71b95f4

Please sign in to comment.