      1 var Ozone = Ozone || {};
      2
      3 /**
      4  * @class
      5  * @description Provides functions to log messages and objects
      6  * @Ozone.log
      7  *
      8  */
      9 /*
     10  * The only function that can be called from gadgets is Ozone.log.gadgetLog
     11  */
     12 Ozone.log = {
     13
     14 };
     15
     16 Ozone.log.logEnabled = false;
     17
     18 Ozone.log.defaultLogger = null;
     19 Ozone.log.defaultAppender = null;
     20
     21 Ozone.log.version = Ozone.version.owfversion + Ozone.version.logging;
     22
     23 /**
     24  * @Ozone.log.getLogger
     25  * @description Get a logger by name, if the logger has not already been created it will be created
     26  * @param {String} loggerName
     27  */
     28 Ozone.log.getLogger = function(loggerName) {
     29     return log4javascript.getLogger(loggerName);
     30 };
     31
     32 /**
     33  * @Ozone.log.setEnabled
     34  * @description Enable/Disable logging for the OWF application
     35  * @param {Boolean} enabled true will enable logging false will disable
     36  */
     37 Ozone.log.setEnabled = function(enabled){
     38 	log4javascript.setEnabled(enabled);
     39 };
     40
     41 /**
     42  * @Ozone.log.getDefaultLogger
     43  * @description Get OWF's default logger
     44  */
     45 //The default logger cannot be used from gadgets
     46 Ozone.log.getDefaultLogger = function() {
     47 	if (!Ozone.log.defaultLogger) {
     48
     49
     50 		var defaultLoggerName = "[ozonedefault]";
     51
     52 		Ozone.log.defaultLogger =  Ozone.log.getLogger(defaultLoggerName);
     53 		Ozone.log.defaultAppender = new log4javascript.PopUpAppender();
     54 		Ozone.log.defaultAppender.setUseOldPopUp(true);
     55 		Ozone.log.defaultAppender.setComplainAboutPopUpBlocking(false);
     56 		// change the logging level here, for example:
     57 		// Ozone.log.defaultAppender.setThreshold(log4javascript.Level.ERROR);
     58         Ozone.log.defaultAppender.setThreshold(log4javascript.Level.OFF);
     59 		log4javascript.getRootLogger().addAppender(Ozone.log.defaultAppender);
     60 		//Ozone.log.defaultAppender.setInitiallyMinimized(true);
     61
     62 		return Ozone.log.defaultLogger;
     63 	}
     64
     65 	return Ozone.log.defaultLogger;
     66 };
     67
     68 /**
     69  * @description Launch the log window pop-up, this will re-launch the window in the event
     70  * it has been closed
     71  */
     72 Ozone.log.launchPopupAppender = function() {
     73
     74 	Ozone.log.defaultAppender.show();
     75
     76 	Ozone.log.getDefaultLogger().debug("Logger Window Lauched");
     77 };
     78
     79
     80 /*
     81  * Log messages from widgets
     82  * @param {Object} message
     83  */
     84 Ozone.log.widgetLog = function() {
     85     gadgets.rpc.call('..', 'Ozone.log',null, arguments);
     86 };
     87
     88
     89 if (typeof(Ext) != "undefined") {
     90 	Ext.onReady(function(){
     91 		gadgets.rpc.register('Ozone.log', function(args){
     92 			var logger = Ozone.log.getDefaultLogger();
     93 			logger.debug.apply(logger, args);
     94 		});
     95 	});
     96 }
     97