本文整理匯總了TypeScript中@sample-stack/utils.logger類的典型用法代碼示例。如果您正苦於以下問題:TypeScript logger類的具體用法?TypeScript logger怎麽用?TypeScript logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了logger類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: callback
origin: (origin, callback) => {
if (corsWhitelist.indexOf(origin) !== -1) {
callback(null, true);
} else {
// TODO: only throw when in debug mode
logger.error('url (%s) is not in the whitelist', origin);
// callback(new Error('Not allowed by CORS'))
logger.warn('allowing all origins temporarily, you need to disable it.');
callback(null, true);
}
},
示例2:
module.hot.status(event => {
if (event === 'abort' || event === 'fail') {
logger.error('HMR error status: ' + event);
// Signal webpack.run.js to do full-reload of the back-end
process.exit(250);
}
});
示例3: stripCircular
(e, req, res, next) => {
if (req.path === pathname) {
const stack = e.stack.toString().replace(/[\n]/g, '\\n');
res.status(200).send(`[{"data": {}, "errors":[{"message": "${stack}"}]}]`);
} else {
logger.error(e);
if (__DEV__ || !assetMap) {
assetMap = JSON.parse(fs.readFileSync(path.join(__FRONTEND_BUILD_DIR__, 'assets.json')).toString());
}
const serverErrorScript = `<script charset="UTF-8">window.__SERVER_ERROR__=${JSON.stringify(
stripCircular(e),
)};</script>`;
const vendorScript = assetMap['vendor.js']
? `<script src="/${assetMap['vendor.js']}" charSet="utf-8"></script>`
: '';
res.status(200).send(
`<html>${serverErrorScript}<body><div id="content"></div>
${vendorScript}
<script src="/${assetMap['index.js']}" charSet="utf-8"></script>
</body></html>`,
);
}
};
示例4: addGraphQLSubscriptions
module.hot.accept(['./api/subscriptions'], () => {
try {
addGraphQLSubscriptions(server);
} catch (error) {
logger.error(error.stack);
}
});
示例5: catch
module.hot.dispose(data => {
try {
(data as any).subscriptionServer = subscriptionServer;
} catch (error) {
logger.error(error.stack);
}
});
示例6: it
it('addCount', async (done) => {
try {
await repo.addCount(1);
done();
} catch (err) {
logger.error(err);
done.fail();
}
});
示例7: catch
module.hot.dispose(() => {
try {
if (server) {
server.close();
}
} catch (error) {
logger.error(error.stack);
}
});