Giter VIP home page Giter VIP logo

angular-remote-logger's Introduction

angular-remote-logger

Build Status Coverage Status Code Climate Dependency Status Dev Dependency Status Bower version

Angular Exception/failed XHR call/$log remote logger

Installation

Bower

  • Add angular-remote-logger as a bower dependency (with the desired version).
  • Reference angular-remote-logger.min.js file (or better yet, use a bower script injector such as main-bower-files for grunt/gulp to automatically add the dependency)

Manually

Copy the file angular dist/angular-remote-logger.min.js into your project and reference it in your app.

Usage

Add the angular module angular-remote-logger as a dependency to your app. For example:

angular.module('myApp', ['angular-remote-logger', ...]);

This will:

  • register an httpInterceptor to log all failed xhr requests
  • register a decorator for the $exceptionHandler provider to log all app exceptions.

Exception logger

Log all application exceptions remotely, with a configurable throttle interval.

Configuration

The parameters can be modified by changing the values of the constant EXCEPTION_LOGGER_CONFIG, as follows

angular.module('angular-remote-logger')
  .config(
    function (EXCEPTION_LOGGER_CONFIG) {
      EXCEPTION_LOGGER_CONFIG.windowInSeconds = 5; //defines the window interval for the throttle checking
      EXCEPTION_LOGGER_CONFIG.maxExceptionsPerWindow = 4; //how many exceptions per window are logged before throttling
      EXCEPTION_LOGGER_CONFIG.remoteLogUrl = 'exception/Logger/Config/Remote/Url'; //remote log endpoint
      EXCEPTION_LOGGER_CONFIG.enabled = false; //disables the exception logger
    }
  );

Remote Payload

The remote logger will POST the exception message & cause

data : {
  exception : exception,
  cause : cause
}

Http Xhr error logger

Log all non-200 xhr responses remotely

Configuration

The parameters can be modified by changing the values of the constant XHR_LOGGER_CONFIG, as follows

angular.module('angular-remote-logger')
  .config(
    function (XHR_LOGGER_CONFIG) {
      XHR_LOGGER_CONFIG.remoteLogUrl = 'xhr/Logger/Config/Remote/Url'; //remote log endpoint
      XHR_LOGGER_CONFIG.enabled = false; //disables the xhr-logger
    }
  );

Remote Payload

The remote logger will POST the entire xhr rejection json object

data: rejection

Log logger

Log all $log call messages remotely

Configuration

The parameters can be modified by changing the values of the constant LOG_LOGGER_CONFIG, as follows

angular.module('angular-remote-logger')
  .config(
    function (LOG_LOGGER_CONFIG) {
      LOG_LOGGER_CONFIG.remoteLogUrl = 'log/Logger/Config/Remote/Url'; //remote log endpoint
      LOG_LOGGER_CONFIG.enabled = {
        global: true, //global flag to disable remote logging for all log operations 
        warn : true, //toggle logging for individual log operations.
        error : true,
        info : true,
        log : true,
        debug : true
      }
    }
  );

Remote Payload

The remote logger will POST the log message, along with the log type:

data:   {
  message: message,
  logType: logType // info/log/debug/error/warn
}

Contributing

Setup Environment

  1. Install node.js, npm for package management
  2. Install bower globally.
  3. Run npm install, bower install to install the build/app dependencies

Tasks

  • Run gulp from the root installation folder to retrieve a list of the available tasks

angular-remote-logger's People

Stargazers

 avatar  avatar

angular-remote-logger's Issues

Add additional logged fields registration capabilities

We want to be able to append to each payload certain fields, like datetime, or user id, or whatever. For this we need a way to register additional fields in each of the fields, which will extend the logged payload object

Add release task

  • Use gulp-bump, gulp tag and gulp-git (also see gulp-release-tasks) to build a gulp release task that will bump package version, build the application for production, tag the release and push it to git master branch.
    • Since we are pushing directly to master without using a pull request, Travis shouldn't retrigger a build

Add payload filter plugin mechanism

We want to be able to transform the logged payload in a certain way, for example strip CC numbers automatically. We need a way to register these filters and run them on the payload object

Add "enabled" configuration variable

We need an "enabled" configuration variable that is true by default for both loggers. That way they can be dynamically disabled.

  • Add a check for the flag in the code, if it's disabled it should do nothing, except return back the chain
  • Update mock configuration/readme with examples
  • Add tests for the disable case to make sure nothing is happening when disabled. Also add tests to dynamically toggle and make sure it works after reenabled.

Fix karma-jasmine version

We need to have the jasmine.clock.mockDate() function available, which is not on the current karma-jasmine version

Add badges

  • Travis (set up travis build)
  • Coveralls
  • Code climate

Add "censor" payload filter

After #17 is implemented, we want to add a filter to censor out certain fields, which can be user defined, such as cc numbers and other financial information for example

Filter should allow for

{
"fieldName" : "type" 
}

where  `type` is remove|censor

Setup configuration / Make tests pass

We need to remove the mocked dashboard variable and mock the constant (if possible), using provider , or otherwise just actually defining the constant, and removing the constant from the actual base code (or check to see if constant can be modified after the fact and code pays attention to it)

Update: We can first try by simply redefining the constant for the module using

module('angular-remote-logger')
  .constant('EXCEPTION_LOGGER_CONFIG', {NEW_OBJECT_WITH_VALUES})

which would be what a regular user would do for configuring the module

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.