本文整理匯總了TypeScript中npmlog.info函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript info函數的具體用法?TypeScript info怎麽用?TypeScript info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了info函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
socket.on('connect', () => {
log.info('Connected to ' + this.getConnectionInfo());
socket.emit(
'room',
'/' + this.coin.toUpperCase() + '/' + this.v8network + '/inv'
);
});
示例2:
const returnError = (err, res, req) => {
if (err instanceof ClientError) {
const status = err.code == 'NOT_AUTHORIZED' ? 401 : 400;
if (!opts.disableLogs)
log.info(
'Client Err: ' + status + ' ' + req.url + ' ' + JSON.stringify(err)
);
res
.status(status)
.json({
code: err.code,
message: err.message
})
.end();
} else {
let code = 500,
message;
if (err && ((err.code && _.isNumber(err.code)) || (err.statusCode && _.isNumber(err.statusCode)))) {
code = err.code || err.statusCode;
message = err.message || err.body;
}
const m = message || err.toString();
if (!opts.disableLogs) log.error(req.url + ' :' + code + ':' + m);
res
.status(code || 500)
.json({
error: m
})
.end();
}
};
示例3: cb
(err, db) => {
if (err) {
log.error('Unable to connect to the mongoDB', err);
return cb(err, null);
}
log.info('Connection established to ' + uri);
this.db = db;
this._getStats((err, stats) => {
if (err) return cb(err);
return cb(null, stats);
});
}
示例4: test
test('request', (t) => {
t.plan(1);
npmlog.level = 'silly';
npmlog.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.info('info prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.http('http prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.error('error prefix', 'x = %j', {foo:{bar:'baz'}});
npmlog.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}});
t.deepEqual(result.join('').trim(), resultExpect.join('').trim(), 'result');
});
示例5:
expressApp.start(config, (err) => {
if (err) {
log.error('Could not start BWS instance', err);
return;
}
server.listen(port);
const instanceInfo = cluster.worker
? ' [Instance:' + cluster.worker.id + ']'
: '';
log.info('BWS running ' + instanceInfo);
return;
});
示例6: icb
.then(ret => {
try {
ret = JSON.parse(ret);
// only process right responses.
if (!_.isUndefined(ret.blocks) && ret.blocks != x) {
log.info(`Ignoring response for ${x}:` + JSON.stringify(ret));
return icb();
}
result[x] = ret.feerate;
} catch (e) {
log.warn('fee error:', e);
}
return icb();
})
示例7: initSocket
initSocket(callbacks) {
log.info('V8 connecting socket at:' + this.host);
// sockets always use the first server on the pull
const socket = io.connect(
this.host,
{ transports: ['websocket'] }
);
socket.on('connect', () => {
log.info('Connected to ' + this.getConnectionInfo());
socket.emit(
'room',
'/' + this.coin.toUpperCase() + '/' + this.v8network + '/inv'
);
});
socket.on('connect_error', () => {
log.error('Error connecting to ' + this.getConnectionInfo());
});
socket.on('tx', callbacks.onTx);
socket.on('block', (data) => {
return callbacks.onBlock(data.hash);
});
socket.on('coin', data => {
// script output, or similar.
if (!data.address) return;
let out;
try {
// TODO
out = {
address: data.address,
amount: data.value / 1e8
};
} catch (e) {
// non parsable address
return;
}
return callbacks.onIncomingPayments({ outs: [out], txid: data.mintTxid });
});
return socket;
}
示例8:
client.on('ready', () => {
log.info('play', 'connected');
client.exec(monogataris.tasks[0].shell, (err, stream) => {
if(err) {
throw err;
}
stream.on('close', (code, signal) => {
log.info('play', `end code:${code}, signal:${signal}`);
client.end();
})
.on('data', data => {
log.info('play', data);
})
.stderr.on('data', data => {
log.error('play', data);
});
});
})
示例9: constructor
constructor(opts) {
super();
opts = opts || {};
if (opts.messageBrokerServer) {
const url = opts.messageBrokerServer.url;
this.remote = true;
this.mq = require('socket.io-client').connect(url);
this.mq.on('connect', () => { });
this.mq.on('connect_error', () => {
log.warn('Error connecting to message broker server @ ' + url);
});
this.mq.on('msg', (data) => {
this.emit('msg', data);
});
log.info('Using message broker server at ' + url);
}
}
示例10: start
/**
* start
*
* @param opts.WalletService options for WalletService class
* @param opts.basePath
* @param opts.disableLogs
* @param opts.doNotCheckV8
* @param {Callback} cb
*/
start(opts, cb) {
opts = opts || {};
this.app.use(compression());
this.app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader(
'Access-Control-Allow-Methods',
'GET, POST, OPTIONS, PUT, DELETE'
);
res.setHeader(
'Access-Control-Allow-Headers',
'x-signature,x-identity,x-session,x-client-version,x-wallet-id,X-Requested-With,Content-Type,Authorization'
);
res.setHeader('x-service-version', WalletService.getServiceVersion());
next();
});
const allowCORS = (req, res, next) => {
if ('OPTIONS' == req.method) {
res.sendStatus(200);
res.end();
return;
}
next();
};
this.app.use(allowCORS);
this.app.enable('trust proxy');
// handle `abort` https://nodejs.org/api/http.html#http_event_abort
this.app.use((req, res, next) => {
req.on('abort', () => {
log.warn('Request aborted by the client');
});
next();
});
const POST_LIMIT = 1024 * 100 /* Max POST 100 kb */;
this.app.use(
bodyParser.json({
limit: POST_LIMIT
})
);
if (opts.disableLogs) {
log.level = 'silent';
} else {
const morgan = require('morgan');
morgan.token('walletId', function getId(req) {
return req.walletId ? '<' + req.walletId + '>' : '<>';
});
const logFormat =
':walletId :remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent" ';
const logOpts = {
skip(req, res) {
if (res.statusCode != 200) return false;
return req.path.indexOf('/notifications/') >= 0;
}
};
this.app.use(morgan(logFormat, logOpts));
}
const router = express.Router();
const returnError = (err, res, req) => {
if (err instanceof ClientError) {
const status = err.code == 'NOT_AUTHORIZED' ? 401 : 400;
if (!opts.disableLogs)
log.info(
'Client Err: ' + status + ' ' + req.url + ' ' + JSON.stringify(err)
);
res
.status(status)
.json({
code: err.code,
message: err.message
})
.end();
} else {
let code = 500,
message;
if (err && ((err.code && _.isNumber(err.code)) || (err.statusCode && _.isNumber(err.statusCode)))) {
code = err.code || err.statusCode;
message = err.message || err.body;
}
const m = message || err.toString();
//.........這裏部分代碼省略.........