]>
Commit | Line | Data |
---|---|---|
db6bc3cb BB |
1 | if (typeof require === 'function') { |
2 | var ioClient = require('socket.io-client'); | |
3 | } | |
bdedb5e5 | 4 | |
db6bc3cb BB |
5 | Class(Cobalt.Logger, 'Socket')({ |
6 | prototype : { | |
7 | serverUrl : '/', | |
bdedb5e5 | 8 | |
db6bc3cb BB |
9 | init : function (config) { |
10 | var logger = this; | |
b39688c9 | 11 | |
db6bc3cb BB |
12 | if (config) { |
13 | for (property in config) { | |
14 | logger[property] = config[property]; | |
c315b8c3 | 15 | } |
db6bc3cb | 16 | } |
c315b8c3 | 17 | |
db6bc3cb BB |
18 | if (!logger.socketIo) { |
19 | logger.socketIo = ioClient; | |
20 | } | |
8da0b42e | 21 | |
db6bc3cb BB |
22 | logger._socket = logger.socketIo.connect(logger.serverUrl); |
23 | }, | |
bdedb5e5 | 24 | |
db6bc3cb BB |
25 | log : function () { |
26 | var i, messageArray = []; | |
71a808fe | 27 | |
db6bc3cb BB |
28 | for (i = 0; i < arguments.length; i++) { |
29 | messageArray.push(arguments[i]); | |
30 | } | |
71a808fe | 31 | |
db6bc3cb BB |
32 | if (this._socket) { |
33 | this._socket.emit('log', messageArray); | |
bdedb5e5 BB |
34 | } |
35 | } | |
bdedb5e5 | 36 | } |
db6bc3cb | 37 | }); |