/** * Flush queued log entries to the file. */ flush() { if (this.queue.length > 0) { // Check filename const filename = this.getFilename(); /*if (filename != this.currentFilename) { this.changeFile(filename); }*/ const rows = Array.from(this.queue); this.queue.length = 0; /* rows.forEach(row => this.writeRow(row)); */ const buf = rows.join(this.opts.eol) + this.opts.eol; return appendFile(filename, buf).catch((err) => { /* istanbul ignore next */ console.debug("Unable to write log file:", filename, err); // eslint-disable-line no-console }); } return Promise.resolve(); }
debug(...args) { // eslint-disable-next-line no-console console.debug(...args); }
function defineModel() { if (isModelDefined) { console.debug('MODEL ALREADY GENERATED'); return; } console.debug("GENERATING THE MODEL"); // Adds the utterances and intents for the NLP manager.addDocument(DEFAULT_LANGUAGE, 'goodbye for now', 'greetings.bye'); manager.addDocument(DEFAULT_LANGUAGE, 'bye bye take care', 'greetings.bye'); manager.addDocument(DEFAULT_LANGUAGE, 'okay see you later', 'greetings.bye'); manager.addDocument(DEFAULT_LANGUAGE, 'bye for now', 'greetings.bye'); manager.addDocument(DEFAULT_LANGUAGE, 'i must go', 'greetings.bye'); manager.addDocument(DEFAULT_LANGUAGE, 'hello', 'greetings.hello'); manager.addDocument(DEFAULT_LANGUAGE, DEFAULT_PHRASE, 'greetings.hello'); manager.addDocument(DEFAULT_LANGUAGE, 'howdy', 'greetings.hello'); // Train also the NLG manager.addAnswer(DEFAULT_LANGUAGE, 'greetings.bye', 'Till next time'); manager.addAnswer(DEFAULT_LANGUAGE, 'greetings.bye', 'see you soon!'); manager.addAnswer(DEFAULT_LANGUAGE, 'greetings.hello', 'Hey there!'); manager.addAnswer(DEFAULT_LANGUAGE, 'greetings.hello', 'Greetings!'); isModelDefined = true; console.debug('MODEL GENERATED'); }
regenerateModel(function() { params.Item = { 'id': MODEL_TABLENAME_KEY, 'model': manager.export() }; console.debug('SAVING MODEL INTO DynamoDB TABLE: ', params); documentClient.put(params, function(errPut, dataPut) { if (errPut) { console.debug('MODEL SAVED INTO DynamDB TABLE: ', dataPut); } else if (!errPut) { console.warning('WITHOUT RESPONSE FROM "put" OPERATION'); console.debug('SETTING THE MODEL RETRIEVED: ', dataGet); manager.import(dataGet.Item.model); } else if (!errGet) { console.debug('DESCRIPTION: ', description); } catch(excp) { console.error('PROBLEMS ON INITIALIZATION OF THE THE MODEL: ', excp);
addTransaction(newTransaction, emit = true) { // It only adds the transaction if it's valid if (this.checkTransaction(newTransaction, this.blocks)) { this.transactions.push(newTransaction); this.transactionsDb.write(this.transactions); console.info(`Transaction added: ${newTransaction.id}`); console.debug(`Transaction added: ${JSON.stringify(newTransaction)}`); if (emit) this.emitter.emit('transactionAdded', newTransaction); return newTransaction; } }
static generateSecret(password) { let secret = crypto.pbkdf2Sync(password, SALT, 10000, 512, 'sha512').toString('hex'); console.debug(`Secret: \n${secret}`); return secret; }
static signHash(keyPair, messageHash) { let signature = keyPair.sign(messageHash).toHex().toLowerCase(); console.debug(`Signature: \n${signature}`); return signature; }
addBlock(newBlock, emit = true) { // It only adds the block if it's valid (we need to compare to the previous one) if (this.checkBlock(newBlock, this.getLastBlock())) { this.blocks.push(newBlock); this.blocksDb.write(this.blocks); // After adding the block it removes the transactions of this block from the list of pending transactions this.removeBlockTransactionsFromTransactions(newBlock); console.info(`Block added: ${newBlock.hash}`); console.debug(`Block added: ${JSON.stringify(newBlock)}`); if (emit) this.emitter.emit('blockAdded', newBlock); return newBlock; } }
static generateKeyPairFromSecret(secret) { // Create key pair from secret let keyPair = ec.keyFromSecret(secret); // hex string, array or Buffer console.debug(`Public key: \n${elliptic.utils.toHex(keyPair.getPublic())}`); return keyPair; }
static verifySignature(publicKey, signature, messageHash) { let key = ec.keyFromPublic(publicKey, 'hex'); let verified = key.verify(messageHash, signature); console.debug(`Verified: ${verified}`); return verified; }
this.client .hsetAsync(room, socketId, JSON.stringify(userObject)) .then( () => console.debug('addUser ', userObject.username + ' added to the room ' + room), err => console.log('addUser', err) )
$vimeo_player.on( "change_state", function() { console.debug( "player state:: ", vimeo_player.state ); if( vimeo_player.state == 0 ) vimeo_player.wrapper.fadeOut( 500, function() { $vimeo_player.v_seekTo( 0 ); } ); } )
/* eslint-env mocha, browser */ /* global proclaim */ describe('console', function () { it('debug()', function () { proclaim.doesNotThrow(function () { console.debug(); }); }); });