Skip to content

AngularJS module (angular-env-logger) with browser console statements restriction based on the application environment.

License

Notifications You must be signed in to change notification settings

mrahulreddy/angular-env-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-env-logger is an angularjs module with logger restriction based on the application environment.

Author: M. Rahul Reddy (RahulReddy)

Usage

  1. Install via either npm or downloaded files:

    1. bower install angular-env-logger
    2. download angular-env-logger.zip
  2. Include dependencies in your HTML.

    1. When using bower:
    <script src="bower_components/angular-env-logger/dist/angular-env-logger.min.js"></script>
    1. when using downloaded files
    <script src="angular-env-logger.min.js"></script>
  3. Add env_logger to your application's module dependencies

    angular.module('app', ['env_logger']);
  4. Use the factory logger

    angular.module('app')
        .controller('appController', function($scope, logger){
    
          logger.configEnv({ //initialize it once for your application
            local : "localhost", // key : window.location.hostname
            dev : "dev.yourHost", // key : window.location.hostname
            prod : "prod.yourHost" // key : window.location.hostname
          })
          logger.enableLogger("local","dev"); //console statements are enabled for given keys.
    
          //In Host http://localhost:8080/your-path, this will be printed
          logger.log("to be seen in local"); //use logger.log/warn/error instead of console.log/warn/error
    
          //In Host http://dev.yourHost/your-path, this will be printed
          logger.log("to be seen in dev"); //use logger.log/warn/error instead of console.log/warn/error
    
          //In Host http://prod.yourHost/your-path, this will NOT be printed
          logger.log("to be seen in prod"); //use logger.log/warn/error instead of console.log/warn/error
    
        });

Note

Use logger.log/warn/error instead of console.log/warn/error

Credits

Alexander Jangam (Alex)

License

MIT

About

AngularJS module (angular-env-logger) with browser console statements restriction based on the application environment.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published