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