Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public debug(msg: string, ...args: any[]): void {
/* istanbul ignore if */
if (log.getLevel() <= LogLevel.DEBUG) {
this.log(LogLevel.DEBUG, msg, args);
}
}
public trace(msg: string, ...args: any[]): void {
/* istanbul ignore if */
if (log.getLevel() <= LogLevel.TRACE) {
this.log(LogLevel.TRACE, msg, args);
}
}
}).then(() => {
// Log transaction excluded it's signatures
if (log.getLevel() === log.levels.DEBUG) {
const filteredTransaction = _.pickBy(transaction.toObject(), (v, k) => k !== 'signatures');
log.debug('Processing Transaction Success\nTransaction:', filteredTransaction);
}
}).catch((error) => {
// Intercept and log error
return new rsvp.Promise(function (resolve, reject) {
postgrator.setConfig({
migrationDirectory: __dirname + '/migrations',
schemaTable: 'xmlforms_migrations',
driver: 'pg',
logProgress: log.getLevel() <= log.levels.DEBUG,
connectionString: postgresUrl
});
postgrator.migrate('201606281159', function(err, migrations) {
if (err) {
reject(err);
} else {
postgrator.endConnection(function() {
resolve(migrations);
});
}
});
});
};
public getLogLevel(): LogLevel {
return log.getLevel();
}
import log from 'loglevel'
import urljoin from 'url-join'
import {
MOCK_WS, SERVER_MESSAGES_COUNTER_PERIOD_SEC, WS_URL
} from '@/common/config'
import ReplayWebSocketMock from '@/mocks/ReplayWebSocketMock'
import LoopGameReplay from '@/mocks/LoopGameReplay'
import WebSocketFactory from './WebSocketFactory'
import SocketController from './SocketController'
const ENABLE_MESSAGE_COUNT_LOGGING = log.getLevel() <= log.levels.DEBUG
const DEFAULT_REPLAY_DELAY = 400
export class SocketControllerFactory {
constructor (id) {
this._id = id
this._socketURL = urljoin(WS_URL, 'games', this._id.toString())
this._initWebSocketFactory()
}
_initWebSocketFactory () {
if (MOCK_WS) {
this._webSocketFactory = new WebSocketFactory(ReplayWebSocketMock, new LoopGameReplay(DEFAULT_REPLAY_DELAY))
} else {
this._webSocketFactory = new WebSocketFactory(WebSocket, this._socketURL)
}