X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/71a808fe142f1c10f9e7de90877fb6e4ffc70158..5c03d3b44c5daeb34180c6922fcf3307f1217cbc:/lib/loggers/socket.js?ds=sidebyside diff --git a/lib/loggers/socket.js b/lib/loggers/socket.js index d9ae055..b057d77 100644 --- a/lib/loggers/socket.js +++ b/lib/loggers/socket.js @@ -4,6 +4,7 @@ // Load up dependencies if (typeof require === 'function') { var Ne = require('neon'); + var ioClient = require('socket.io-client'); Module = Ne.Module; Class = Ne.Class; } else { @@ -18,8 +19,20 @@ prototype : { serverUrl : '/', - init : function () { - this._socket = io.connect(this.serverUrl); + init : function (config) { + var logger = this; + + if (config) { + for (property in config) { + logger[property] = config[property]; + } + } + + if (!logger.socketIo) { + logger.socketIo = ioClient; + } + + logger._socket = logger.socketIo.connect(logger.serverUrl); }, log : function () { @@ -29,7 +42,9 @@ messageArray.push(arguments[i]); } - this._socket.emit('log', messageArray); + if (this._socket) { + this._socket.emit('log', messageArray); + } } } });