Skip to content

andischerer/cordova-plugin-logtofile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Cordova plugin for custom logging to a logfile in the filesystem.

Resources

License

Stars

Watchers

Forks

Packages

No packages published