Git Product home page Git Product logo

noisify's Introduction

noisify

A Ruby script that creates a "noisy_*.js" file for the provided JavaScript file that attempts to console.log most function calls with the function name and argument values. This way it has a chance to work even in strict mode, because the log statement that is injected is determined by parsing the provided javascript, not at runtime.

Use at your own risk! The modified file may not work.

Usage

./noisify some_file.js

Specify one or more lines not to noisify (function definitions that occur in places that make it difficult for noisify to modify easily):

./noisify some_file.js 5,19,56

If you want to run JSHint before and after and diff (requires jshint and diff):

./noisify some_file.js 5,19,56 --jshint

Example

Noisify Angular v1.1.5 (excluding line# 6339 which defines consoleLog):

wget https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js
./noisify angular.js 6339

Then just back your original angular.js in your project and replace it with noisy_angular.js. Resulting hacked version of angular not work properly for you, but seemed to when I tried. Please do not report issues to the Angular team related to your modified version.

If you:

diff angular.js noisy_angular.js

among many other changes, you'll see:

< function forEach(obj, iterator, context) {
---
> function forEach(obj, iterator, context) {console.log('function forEach(' + [].slice.call( arguments ) + ')');

And when you run in console.log, among the other many log statements, it might contain something like the following, indicating the forEach was called with an empty argument and the following anonymous function:

function forEach(,function (attr) {
            console.log('function(' + [].slice.call(arguments) + ')');
            if (!appElement && names[attr.name]) {
              appElement = element;
              module = attr.value;
            }
          }) 

and when that anonymous function is called, it gets logged, and so on. Yay trace logging!

When done tracing an issue, replace the JavaScript file with the original version.

License

Copyright (c) 2013 Gary S. Weaver, under the MIT license.

noisify's People

Contributors

garysweaver avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.