Improve error logging

This commit is contained in:
Julien Bisconti 2020-04-13 16:32:38 +02:00
parent 9ce3b26392
commit 3ddaea3999
No known key found for this signature in database
GPG Key ID: 62772C6698F736CB

View File

@ -35,9 +35,12 @@ const make_GQL_options = (query) => ({
}); });
const LOG = { const LOG = {
error: (...args) => console.error('❌ ERROR', { ...args }), error: (...args) => console.error('❌ ERROR', args),
error_string: (...args) => error_string: (...args) =>
console.error('❌ ERROR', JSON.stringify({ ...args })), console.error(
'❌ ERROR',
args.map((a) => JSON.stringify(a)),
),
debug: (...args) => { debug: (...args) => {
if (process.env.DEBUG) console.log('>>> DEBUG: ', { ...args }); if (process.env.DEBUG) console.log('>>> DEBUG: ', { ...args });
}, },
@ -139,7 +142,7 @@ async function main() {
const links = extract_all_links(markdown); const links = extract_all_links(markdown);
const duplicates = find_duplicates(links); const duplicates = find_duplicates(links);
if (duplicates.length > 0) { if (duplicates.length > 0) {
LOG.error_string({ duplicates }); LOG.error('duplicates', duplicates);
} }
const [github_links, other_links] = partition(links, (link) => const [github_links, other_links] = partition(links, (link) =>
link.startsWith('https://github.com'), link.startsWith('https://github.com'),
@ -152,7 +155,7 @@ async function main() {
BATCH_SIZE: 8, BATCH_SIZE: 8,
}); });
if (other_links_error.length > 0) { if (other_links_error.length > 0) {
LOG.error_string({ other_links_error }); LOG.error('other_links_error', other_links_error);
} }
const repos = extract_repos(github_links); const repos = extract_repos(github_links);