2015-09-04 12:10:08 +02:00
|
|
|
var debug = require('debug');
|
|
|
|
var util = require('util');
|
|
|
|
|
|
|
|
module.exports = function createLogger(namespace) {
|
|
|
|
var logger = debug('pitaya:'+namespace);
|
2015-09-11 16:25:45 +02:00
|
|
|
var isNWContext = 'window' in global;
|
|
|
|
var console = isNWContext ? global.window.console : global.console;
|
2015-09-04 12:10:08 +02:00
|
|
|
logger.log = function() {
|
2015-09-11 16:25:45 +02:00
|
|
|
if(isNWContext) {
|
|
|
|
console.log.apply(console, arguments);
|
|
|
|
} else {
|
|
|
|
var str = util.format.apply(util, arguments);
|
|
|
|
console.log(str);
|
|
|
|
}
|
2015-09-04 12:10:08 +02:00
|
|
|
};
|
|
|
|
return logger;
|
|
|
|
};
|