本文整理汇总了TypeScript中loge.logger.debug方法的典型用法代码示例。如果您正苦于以下问题:TypeScript logger.debug方法的具体用法?TypeScript logger.debug怎么用?TypeScript logger.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loge.logger
的用法示例。
在下文中一共展示了logger.debug方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mergeAverageDownloadsPerDay
mergeAverageDownloadsPerDay(packages, (error, packages) => {
if (error) return callback(error);
logger.debug('updating with %d packages (%s)', packages.length, updates_only ? 'updates only' : 'all packages');
var batches = _.chunk(packages, 500);
async.eachSeries(batches, insertPackages, callback);
});
示例2: normalizePackage
fs.readFile(REGISTRY_CACHE_FILEPATH, {encoding: 'utf8'}, (err, data) => {
// all we need from the cache is the latest `_updated` value
if (err || data === '') {
data = '{"_updated":0}';
}
var registry = JSON.parse(data);
var _updated: number = registry._updated;
// updating the locally-cached registry file happens the same way regardless
// of the updates_only flag
var url = `https://registry.npmjs.org/-/all/since?stale=update_after&startkey=${_updated}`;
logger.debug('fetching url: "%s"', url);
request.get({url: url, json: true}, (error, response, body) => {
if (error) return callback(error);
logger.debug('fetched %d updates', Object.keys(body).length - 1);
// update and save the cached registry, but don't wait for it
_.assign(registry, body);
fs.writeFile(REGISTRY_CACHE_FILEPATH, JSON.stringify(registry), {encoding: 'utf8'}, (error) => {
if (error) {
return logger.error('failed to save registry: %s', error.message);
}
logger.debug('saved updated registry file');
});
var names = updates_only ? Object.keys(body) : Object.keys(registry);
var packages = names.filter(name => name !== '_updated').map(name => normalizePackage(registry[name]));
callback(null, packages);
});
});
示例3: insertPackages
function insertPackages(packages: registry.Package[], callback: (error?: Error) => void) {
logger.debug('inserting batch of %d packages, from %s to %s', packages.length,
packages[0].name, packages[packages.length - 1].name);
var body = [];
packages.forEach(pkg => {
body.push({index: {_id: pkg.name}}, pkg);
});
client.bulk({
index: 'npm',
type: 'packages',
body: body
}, (error: Error, result) => {
if (error) {
logger.error('failed to insert batch: %s', error.message);
return callback(error);
}
logger.debug('inserting batch took %d ms', result.took);
if (result.errors) {
logger.warning('batch insert encountered non-fatal errors: %j', result.errors);
}
callback();
});
}
示例4: determineNeededEndpoints
.execute((selectError: Error, local_statistics: Statistic[]) => {
if (selectError) return callback(selectError)
// 2. determine what we want to get next
const [start, end] = determineNeededEndpoints(local_statistics, min_range_days, max_range_days)
// 3. determineNeededEndpoints may return [null, null] if there are no
// remaining ranges that we need to fetch
if (start === null && end === null) {
logger.debug('not fetching any data for "%s"', name)
return callback(null, local_statistics)
}
// 4. get the next unseen statistics
getRangeStatistics(name, start, end, (statsError, statistics) => {
if (statsError) return callback(statsError)
// 5. save the values we just fetched
const [sql, args] = buildMultirowInsert(package_row.id, statistics)
db.executeSQL(sql, args, (sqlError: Error) => {
if (sqlError) return callback(sqlError)
// 6. merge local and new statistics for the response
const total_statistics = statistics.concat(local_statistics).sort((a, b) => a.day.getTime() - b.day.getTime())
callback(null, total_statistics)
})
})
})
示例5: Parser
readableStream.pipe(new Parser({lowerCaseTags: argv.lower === true})).on('finish', function() {
logger.debug('document=%j', this.document);
const xmlSerializer = new XMLSerializer(' ', argv.limit);
const formattedHTML = xmlSerializer.serializeToString(this.document);
process.stdout.write(formattedHTML);
process.stdout.write('\n');
});
示例6:
const server = http.createServer((req, res) => {
logger.debug('%s %s', req.method, req.url)
// enable CORS
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', '*')
controller.route(req, res)
})
示例7: callback
request.get({url: url, json: true}, (error, response, body: {[index: string]: number}) => {
if (error) return callback(error);
logger.debug('fetched download counts for %d packages', Object.keys(body).length);
packages.forEach(pkg => {
pkg.averageDownloadsPerDay = body[pkg.name] || 0;
});
callback(null, packages);
});
示例8: name
/**
Given a package name (string) and start/end dates, call out to the NPM API
download-counts endpoint for that range. Collect these into a proper array of
Statistic objects, where `downloads` is zero for the days omitted from the response.
*/
function getRangeStatistics(name: string, start: moment.Moment, end: moment.Moment,
callback: (error: Error, statistics?: Statistic[]) => void) {
const url = `https://api.npmjs.org/downloads/range/${start.format('YYYY-MM-DD')}:${end.format('YYYY-MM-DD')}/${name}`
logger.debug('fetching "%s"', url)
request.get({url, json: true}, (error: Error, response: http.IncomingMessage, body: DownloadsRangeResponse) => {
if (error) return callback(error)
let downloads_default = 0
if (body.error) {
// we consider missing stats (0008) a non-fatal error, though I'm not sure
// what causes it. but instead of setting the downloads for those dates to 0,
// which is probably what the server means, we set them to -1 (as a sort of error value)
if (body.error == 'no stats for this package for this range (0008)') {
body.downloads = []
downloads_default = -1
}
else {
return callback(new Error(body.error))
}
}
logger.debug('retrieved %d counts', body.downloads.length)
// body.downloads is a list of Statistics, but it's not very useful because
// it might be missing dates.
const downloads: {[day: string]: number} = {}
body.downloads.forEach(download => downloads[download.day] = download.downloads)
// The start/end in the response should be identical to the start/end we
// sent. Should we check?
const statistics: Statistic[] = []
// Use start as a cursor for all the days we want to fill
while (!start.isAfter(end)) {
const day = start.format('YYYY-MM-DD')
statistics.push({
day: start.clone().toDate(),
downloads: downloads[day] || downloads_default,
})
start.add(1, 'day')
}
callback(null, statistics)
})
}