Open eoherrer opened 7 years ago
I am able to write to file but it does not append to an existing file!
Hi AramVave! here's my ionic code:
declare var logToFile: any;
initLogToFile(): Promise
this.checkAddPermission()
.then(granted => {
if (granted) {
logToFile.setLogfilePath(`${this.log.filePath}/${this.log.currentFileName}`, function () {
console.log("LogToFile Configured...");
resolve(true)
}, function (err) {
console.log("LogToFile Error on Configure...: " + err);
reject(false);
});
} else {
console.log("Permission was not granted, the log will not work");
}
})
.catch(err => {
console.log("Error on granting permission: " + err);
});
});
}
checkAddPermission(): Promise
permissions.checkPermission(permissions.WRITE_EXTERNAL_STORAGE, function (status) {
if (status.hasPermission) {
console.log("Yes :D ");
resolve(true);
}
else {
console.log("No :( ");
permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE, function (status) {
if (status.hasPermission) {
console.log("Permission is now granted");
resolve(true);
} else {
console.log('Permission is not turned on');
resolve(false);
}
}, function (err) {
console.log("Error requesting permission :" + err);
reject(err);
});
}
});
});
}
write(message: string) { //Public Method to call write everywere if (this.settingsService.developerMode) console.log(message);
logToFile.info(message);
}
Regards!!
Hi! I try it to use in Ionic2 App, the configure process say's that was configured successfully, but when I trying to use the writing any of the above, It doesn't do anything, doesn't throw any error, and also debug with the Android Studio with Logcat and nothing appears, do you know why??
window.logToFile.debug('Sample debug message'); window.logToFile.info('Sample info message'); window.logToFile.warn('Sample warn message'); window.logToFile.error('Sample error message');
Thanks in advance.