X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/c35e454310676fa3fca931bdb5c4e56a01775ef4..b8f42ab9cc981cbf82418b07f630732365108d14:/lib/loggers/socket.js 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); + } } } });