npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ionic-filelogger-pp-fork

v1.3.3

Published

[![npm](https://img.shields.io/npm/v/ionic-filelogger.svg)](https://www.npmjs.com/package/ionic-filelogger) [![Bower](https://img.shields.io/bower/v/filelogger.svg)](http://bower.io/search/?q=filelogger)

Downloads

3

Readme

Ionic File Logger

npm Bower

Logger module for Ionic projects.

When you run your application in device the Logger writes in the local filesystem (with cordova-plugin-file) and the system logs (with console.log).

When you run your application in browser with „ionic serve” the Logger uses browsers localStorage and the browser console (with console.log).

Dependencies

Installation

Add cordova plugin:

$ cordova plugin add cordova-plugin-file

Install manually, or from bower:

$ bower install filelogger

Install with npm:

$ npm install ionic-filelogger

Include filelogger.min.js and ng-cordova.js or ng-cordova.min.js in your index.html file before cordova.js and after your AngularJS / Ionic file (since ngCordova depends on AngularJS).

<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<script src="lib/filelogger/dist/filelogger.min.js"></script>
<script src="cordova.js"></script>

Comment: you don't have to use the complete ngCordova package. I suggest to create a Custom Build with file module.

Usage

$fileLogger.log(level, ...message)

General logger method. The first parameter is the log level (debug, info, warn, error). The following parameters are the message parts. You can put here any javascript type (string, number, boolean, object, array).

In the logfile every item starts with the current UTC timestamp, followed by the log level and the message.

$fileLogger.debug(...message)

Wrapper for $fileLogger.log('debug', ...)

$fileLogger.info(...message)

Wrapper for $fileLogger.log('info', ...)

$fileLogger.warn(...message)

Wrapper for $fileLogger.log('warn', ...)

$fileLogger.error(...message)

Wrapper for $fileLogger.log('error', ...)

$fileLogger.setStorageFilename(filename)

You can set the local filename (default messages.log). It requests one parameter, the filename (type string).

$fileLogger.setTimestampFormat(format, timezone)

You can customize the timestamp format using Angular date filter. See formatting parameters on the linked Angular docs page. Example:

$fileLogger.setTimestampFormat('medium');

$fileLogger.getLogfile()

You can read the whole logfile from the filestore. This method returns a promise.

$fileLogger.deleteLogfile()

You can delete the logfile from the filestore. This method returns a promise.

$fileLogger.checkFile()

Get storage file data. This method returns an object.

// response on iOS
{
  "name": "myLog.txt",
  "localURL": "cdvfile://localhost/library-nosync/myLog.txt",
  "type": null,
  "lastModified": 1435668606000,
  "lastModifiedDate": 1435668606000,
  "size": 450,
  "start": 0,
  "end": 450
}

// response on Android
{
  "name": "myLog.txt",
  "localURL": "cdvfile://localhost/files/myLog.txt",
  "type": "text/plain",
  "lastModified": 1435669292000,
  "lastModifiedDate": 1435669292000,
  "size": 450,
  "start": 0,
  "end": 450
}

// response in Browser
{
  "name": "myLog.txt",
  "localURL": "localStorage://localhost/myLog.txt",
  "type": "text/plain",
  "size": 450
}

Example use

angular.module('starter', ['ionic', 'fileLogger'])
  .controller('mainCtrl', ['$scope', '$fileLogger', '$timeout', function($scope, $fileLogger, $timeout) {

  function testing() {

    $fileLogger.setStorageFilename('myLog.txt');

    $fileLogger.log('debug', 'message');
    $fileLogger.log('info', 'message');
    $fileLogger.log('warn', 'message');
    $fileLogger.log('error', 'message');

    $fileLogger.debug('message');
    $fileLogger.info('message');
    $fileLogger.warn('message');
    $fileLogger.error('message');

    $fileLogger.log('error', 'error message', { code: 1, meaning: 'general' });

    $fileLogger.log('info', 'message', 123, [1, 2, 3], { a: 1, b: '2' });

    $timeout(function(){
      $fileLogger.getLogfile().then(function(l) {
        console.log('Logfile content');
        console.log(l);
      });
    }, 1000);

    $timeout(function(){
      $fileLogger.checkFile().then(function(d) {
        console.log('Logfile data');
        console.log(JSON.stringify(d));
      });
    }, 2000);

    $timeout(function(){
      $fileLogger.deleteLogfile().then(function() {
        console.log('Logfile deleted');
      });
    }, 3000);

  }

}]);

Author

Peter Bakondy

  • https://github.com/pbakondy

LICENSE

Ionic File Logger is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.