-(function (global) {
- var Module, Class;
-
- // Load up dependencies
- if (typeof require === 'function') {
- var Ne = require('neon');
- Module = Ne.Module;
- Class = Ne.Class;
- } else {
- Module = global.Module;
- Class = global.Class;
- }
-
- var Cobalt = {};
- Module(Cobalt, 'Logger')({});
+if (typeof require === 'function') {
+ var ioClient = require('socket.io-client');
+}
- Cobalt.Logger.Socket = Class(Cobalt.Logger, 'Socket')({
- prototype : {
- serverUrl : '/',
+Class(Cobalt.Logger, 'Socket')({
+ prototype : {
+ serverUrl : '/',
- init : function (config) {
- var logger = this;
- logger.socketIo = io;
+ init : function (config) {
+ var logger = this;
- if (config) {
- for (property in config) {
- logger[property] = config[property];
- }
+ if (config) {
+ for (property in config) {
+ logger[property] = config[property];
}
+ }
- logger._socket = logger.socketIo.connect(logger.serverUrl);
- },
+ if (!logger.socketIo) {
+ logger.socketIo = ioClient;
+ }
- log : function () {
- var i, messageArray = [];
+ logger._socket = logger.socketIo.connect(logger.serverUrl);
+ },
- for (i = 0; i < arguments.length; i++) {
- messageArray.push(arguments[i]);
- }
+ 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 {
- global.Cobalt.Logger.Socket = Cobalt.Logger.Socket;
}
-}(typeof window !== 'undefined' ? window : (typeof exports !== 'undefined' ? exports : self)));
+});