Javascript logging setup for unit testing and running browser based web app -


i working on client side javascript web app. using log4javascript logging application functionality while running on local server , becuase couldn't log4javascript work during unit testing (in either jasmine+karma or mocha), using log4js logging while running unit tests on node using mocha.

to log during normal webb app running create log4javascript logger html page (as cant figure out way create glogal logger javascript.js file) using:

<script src="{{ url_for('static', filename='js/log4javascript.js') }}" type="text/javascript"></script> <script type="text/javascript">     var logger = log4javascript.getdefaultlogger(); </script>  

beacause want log console during unit testing need set-up log4js in same javascript.js files logging during normal web app running from. ie:

var log4js = require('log4js'); log4js.configure({     appenders: [         {             "type": "loglevelfilter",             "level": "debug",             "appender":             {                 "type": "console"             }         }     ] }); var logger = log4js.getlogger(); 

then inside functions can use:

logger.debug("functionname message"); 

and work when logging log4javascript , log4js, messy have require('log4js') statements (that seem ignored when running on browser) in every javascript file , there 2 meanings logger. there better way use logging during development of browser based javascript?

i ended using console.log in application code , winston logger unit testing.

a example of how console.log can overriden can found here: http://seanmonstar.com/post/56448644049/consolelog-all-the-things


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -