eventLog static method
Implementation
static Future<void> eventLog({
String className = "",
String methodName = "",
String url = "",
String postRequest = "",
String postResponse = "",
String appLog = "",
}) async {
try {
final String filePath = await getLogFilePath();
final File file = File(filePath);
final String classN = className.isNotEmpty
? "[ ${LogConstants.className} $className ] |"
: "";
final String methodN = methodName.isNotEmpty
? "[ ${LogConstants.methodName} $methodName ] |"
: "";
final String urlEnd =
url.isNotEmpty ? "[ ${LogConstants.apiUrl} $url} ] |" : "";
final String pRequest = postRequest.isNotEmpty
? "[ ${LogConstants.apiRequest} $postRequest ] |"
: "";
final String log =
appLog.isNotEmpty ? "[ ${LogConstants.appLog} $appLog ]" : "";
String finalLog =
"${DateTime.now().toLocal()} ${classN.isNotEmpty ? classN : ""} ${methodN.isNotEmpty ? methodN : ""} ${urlEnd.isNotEmpty ? urlEnd : ""} ${pRequest.isNotEmpty ? pRequest : ""} ${postResponse.isNotEmpty ? postResponse : ""} ${log.isNotEmpty ? log : ""} \n";
file.writeAsStringSync(
finalLog,
mode: FileMode.append,
);
} catch (e) {
if (kDebugMode) {
print(e);
}
}
}