cordova-plugin-logtofile

1.1.2 • Public • Published

cordova-plugin-logtofile

Cordova plugin for writing logs to the filesystem.

Logger uses logback-android internally.

Installation

cordova plugin add cordova-plugin-logtofile

Usage

// setup a logfile path (required)
// this path is relative to your device sdcard storage directory
window.logToFile.setLogfilePath('/myapp/log.txt', function () {
    // logger configured successfully  
}, function (err) {
    // logfile could not be written
    // handle error
});
 
// get the logfilePath from the currently running logger instance
window.logToFile.getLogfilePath(function (logfilePath) {
    // dosomething with the logfilepath
}, function (err) {
    // handle error
});
 
// get the all archived logfile paths as array
window.logToFile.getArchivedLogfilePaths(function (archivedlogfiles) {
    // dosomething with the archived logs
}, function (err) {
    // handle error
});
 
// write logmessages in different loglevels
window.logToFile.debug('Sample debug message');
window.logToFile.info('Sample info message');
window.logToFile.warn('Sample warn message');
window.logToFile.error('Sample error message');

Logrotate

If the logfile exceeds a filesize above 5MB the current logfile will be archived and zipped into the current logfiledirectory. The last 3 archived logfiles will be retained, older logs get deleted. The archived logfiles are reachable under the following filepattern: {logfiledirectory}/{logfilename}.{index}.zip

Currently supported Platforms

  • Android

TODOs

  • add more config options

Package Sidebar

Install

npm i cordova-plugin-logtofile

Weekly Downloads

53

Version

1.1.2

License

MIT

Last publish

Collaborators

  • andischerer