I have a logger implementation that support contexts, loglevels, and appenders used during development. I'd like to remove all logging code for production. Below is an example of a module in my codebase. I've added comments around what I want to be removed.
```js
!function($, Application, Logger, exports) {
// START REMOVE
Logger.configure([
{context: 'nike.profile.core.Application', level: Logger.LOG, save: true},
{context: 'nike.profile.models.Account', level: Logger.WARN, save: true},
{context: 'nike.profile.models.User', level: Logger.INFO, save: true}
]);
// END REMOVE
// START REMOVE
var logger = Logger.getLogger(exports.namespace+'.app');
// END REMOVE
// Create an instance of Application
var app = new Application();
// Only one Application instance should exist
$(function() {
// START REMOVE
logger.log('Log');
logger.debug('Debug');
logger.warn('Warning');
logger.error('Error');
// END REMOVE
app.start();
}(
window.jQuery,
window.nike.profile.core.Application,
window.nike.util.Logger,
window.nike.ns('nike.profile')
);
```js
As you can see, I'd like to find any use of the `Logger` class and remove it. In addition, I'd like to remove all code that uses instances of the Logger class as well.
I need to analyze the code to determine when an instance of Logger is created, note the name of that instance, and then remove any code that use that name. Obviously, this could get complex if usage is embedded within lines of code.
To simplify things, I can make sure that all usage of the code I'm trying to replace is limited to lines of code that follow the following formats:
Logger.configure(...);
var logger = Logger.getLogger(...);
logger.log(...);
I can also make sure to be consistent about how I name logger instances. I can make sure that all instances begin with the name `logger`. This would include `logger`, `logger1`, `logger_xyz`, etc. No other non-logging variable names used anywhere in the application would start with the word `logger`.
Tauren