]> git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/socket.js
70662748cea12f93319e451a969fd447efbf43e9
[rbdr/cologne] / lib / loggers / socket.js
1 if (typeof require === 'function') {
2 var ioClient = require('socket.io-client');
3 }
4
5 Class(Cobalt.Logger, 'Socket')({
6 prototype : {
7 serverUrl : '/',
8
9 init : function (config) {
10 var logger = this;
11
12 if (config) {
13 for (property in config) {
14 logger[property] = config[property];
15 }
16 }
17
18 if (!logger.socketIo) {
19 logger.socketIo = ioClient;
20 }
21
22 logger._socket = logger.socketIo.connect(logger.serverUrl);
23 },
24
25 log : function () {
26 var i, messageArray = [];
27
28 for (i = 0; i < arguments.length; i++) {
29 messageArray.push(arguments[i]);
30 }
31
32 if (this._socket) {
33 this._socket.emit('log', messageArray);
34 }
35 }
36 }
37 });