X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/bdedb5e54032363de8afa322fadae0e2cb2132d0..f6cd3c16e9c98f18c877c66a927bb39cf968b4db:/lib/loggers/socket.js diff --git a/lib/loggers/socket.js b/lib/loggers/socket.js index 8d0ff55..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,16 +19,40 @@ 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 (logObject) { - this._socket.emit('log', logObject); + log : function () { + var i, messageArray = []; + + for (i = 0; i < arguments.length; i++) { + messageArray.push(arguments[i]); + } + + if (this._socket) { + this._socket.emit('log', messageArray); + } } } }); + if (Cobalt.Logger.Socket.__objectSpy) { + Cobalt.Logger.Socket.__objectSpy.destroy(); + } + if (typeof require === 'function') { global.Socket = Cobalt.Logger.Socket; } else {