pbakondy / filelogger

:memo: Ionic File Logger
MIT License
20 stars 14 forks source link

proposal: add option to change cordova.file.dataDirectory to cordova.file.externalDataDirectory #35

Open hreimer opened 6 years ago

hreimer commented 6 years ago

Hi, upon testing your plugin I found that if a internal webserver is used*, the log file is stored under cdvfile://localhost/files/.txt, which (in my case) is inaccessible although it gets written, it's just useless for further debugging if it only persists in an inaccessible location during runtime.

I found in your sourcecode, if I changed all appearances of cordova.file.dataDirectory to cordova.file.externalDataDirectory the file gets created and I can find it under /Android/data//files/.txt. For now I will fork your plugin, however I thought maybe others faced the same issues and a fileDirectory option would be a nice addition.

*see these plugins: cocoon-cordova-labs-local-webserver, cocoon-cordova-labs-wkwebview-engine-localhost, cocoon-cordova-plugin-wkwebview-engine

Using Ionic 1.3.3 & cordova 6.5.0, my device is a Samsung Galaxy J3 2016

robindierckx commented 6 years ago

+1

pliablepixels commented 6 years ago

We can't change everything to cordova.file.externalDataDirectory as that breaks iOS. cordova.file.dataDirectory is correct and works on both Android and iOS.

When you do $filelogger.checkFile() it returns a name. All you need to do is:

var myFileWithPath = cordova.file.dataDirectory + result.name // result is the return object from checkFile

And you'll get the full path with file. Verified with wkwebview and iOS and Android. Sample code.