User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:devel:jsdebuging [2018/06/01 16:28]
joebordes created
en:devel:jsdebuging [2018/06/01 16:47] (current)
joebordes [Browser console]
Line 3: Line 3:
 Due to the popularity of javascript and it's importance inside web applications (coreBOS), as of June 2018 coreBOS has added functionality to be able to log messages that happen in your javascript code to the backend logging system. Due to the popularity of javascript and it's importance inside web applications (coreBOS), as of June 2018 coreBOS has added functionality to be able to log messages that happen in your javascript code to the backend logging system.
  
-In order for this to work we must load the coreBOS webservice library in order to make web services calls and the logging javascript library. This can be done by adding this code to your project:+to get this to work we must
 + 
 +  * load the coreBOS webservice library in order to make web services calls 
 +  * load the logging javascript library. This can be done by adding this code to your project:
  
 <code html> <code html>
Line 14: Line 17:
 </​code>​ </​code>​
  
-Once that code has been included we will have a logging object at our service that is called jslog and has this interface:+Once that code has been included we will have a logging object at our service that is called ​**jslog** and has this interface:
  
 ====jslog(connection,​ level, message)==== ====jslog(connection,​ level, message)====
  
 <code javascript>​ <code javascript>​
-jslog(cbws, '​fatal',​ message);+jslog(cbws, '​fatal', ​'message ​to log');
 </​code>​ </​code>​
  
Line 39: Line 42:
  
 <code javascript>​ <code javascript>​
-jslogjslog2console ​= true;+jslog.jslog2console ​= true;
 </​code>​ </​code>​
  
 +====Deactivate logging ====
 +
 +In certain situations it could be useful to keep the logging messages around while we are tacking down some hard to find bug but we want to deactivate them temporarily. **jslog** has a settings option for this called **active**
 +
 +<code javascript>​
 +jslog.active = false;
 +</​code>​
 +
 +
 +====Examples ====
 +
 +<code javascript>​
 +jslog.fatal(cbws,​ JSON.stringify({'​var1':'​kdkdkd','​var2':'​llll'​}));​
 +jslog.debug(cbws,​ "​{'​var1':'​kdkdkd','​var2llll'​}"​);​
 +jslog.jslog2console=true;​
 +jslog(cbws, '​info',​ "this message will appear in the console also!"​);​
 +</​code>​
  
 +====Destination log file ====
  
 +The messages sent to the backend will appear in the file **logs/​javascript.log** and you must have the [[en:​devel:​debuging#​php|log4php.properties settings file configured correctly]] as well as the $LOG4PHP_DEBUG = true; variable.