Browse Source

Refactor log messages for download and parsing events to be more concise and remove unnecessary information

node16
Onja 12 months ago
parent
commit
fb9e493da6
  1. 25
      src/subscribers/consoleSubscriber.js

25
src/subscribers/consoleSubscriber.js

@ -10,22 +10,22 @@ const log = (event, data) => {
// Create a new listener for the download.start event // Create a new listener for the download.start event
emitter.on('download.start', ({ url, filepath }) => { emitter.on('download.start', ({ url, filepath }) => {
log('download.start', `Downloading ${url} to ${filepath}`); log('download.start', `Downloading to ${filepath}`);
}); });
// Create a new listener for the download.end event // Create a new listener for the download.end event
emitter.on('download.end', ({ url, filepath }) => { emitter.on('download.end', ({ url, filepath }) => {
log('download.end', `Downloaded ${url} to ${filepath}`); log('download.end', `Downloaded to ${filepath}`);
}); });
// Create a new listener for the download.error event // Create a new listener for the download.error event
emitter.on('download.error', ({ url, filepath, error, type }) => { emitter.on('download.error', ({ url, filepath, error, type }) => {
log('download.error', `Error [${type}] downloading ${url} to ${filepath}: ${error}`); log('download.error', `Error [${type}] downloading to ${filepath}: ${error}`);
}); });
// Create a new listener for the download.progress event // Create a new listener for the download.progress event
emitter.on('download.progress', ({ url, filepath, percentage }) => { emitter.on('download.progress', ({ url, filepath, percentage }) => {
log('download.progress', `Downloaded ${percentage}% of ${url} to ${filepath}`); log('download.progress', `Downloaded ${percentage}% to ${filepath}`);
}); });
@ -34,17 +34,20 @@ emitter.on('download.progress', ({ url, filepath, percentage }) => {
// Create a new listener for the parseFromUrl.start event // Create a new listener for the parseFromUrl.start event
emitter.on('parseFromUrl.start', ({ url, columns }) => { emitter.on('parseFromUrl.start', ({ url, columns }) => {
log('parseFromUrl.start', `Parsing ${url} with columns [${columns.join(', ')}]`); // log('parseFromUrl.start', `Parsing ${url} with columns [${columns.join(', ')}]`);
log('parseFromUrl.start', `Parsing with columns`);
}); });
// Create a new listener for the parseFromUrl.end event // Create a new listener for the parseFromUrl.end event
emitter.on('parseFromUrl.end', ({ url, columns, filepath }) => { emitter.on('parseFromUrl.end', ({ url, columns, filepath }) => {
log('parseFromUrl.end', `Parsed ${url} with columns ${columns.join(', ')} to ${filepath}`); // log('parseFromUrl.end', `Parsed ${url} with columns ${columns.join(', ')} to ${filepath}`);
log('parseFromUrl.end', `Parsed with columns to ${filepath}`);
}); });
// Create a new listener for the parseFromUrl.error event // Create a new listener for the parseFromUrl.error event
emitter.on('parseFromUrl.error', ({ url, columns, error }) => { emitter.on('parseFromUrl.error', ({ url, columns, error }) => {
log('parseFromUrl.error', `Error parsing ${url} with columns ${columns.join(', ')}: ${error}`); // log('parseFromUrl.error', `Error parsing ${url} with columns ${columns.join(', ')}: ${error}`);
log('parseFromUrl.error', `Error parsing with columns: ${error}`);
}); });
@ -53,20 +56,20 @@ emitter.on('parseFromUrl.error', ({ url, columns, error }) => {
// Create a new listener for the parse start event // Create a new listener for the parse start event
emitter.on('parse.start', ({ filepath, columns, headers }) => { emitter.on('parse.start', ({ filepath, columns, headers }) => {
log('parse.start', `Parsing ${filepath} with columns ${columns.join(', ')} and headers ${headers.join(', ')}`); log('parse.start', `Parsing ${filepath} with columns and headers ${headers.join(', ')}`);
}); });
// Create a new listener for the parse.end event // Create a new listener for the parse.end event
emitter.on('parse.end', ({ filepath, columns, count }) => { emitter.on('parse.end', ({ filepath, columns, count }) => {
log('parse.end', `Parsed ${filepath} with columns ${columns.join(', ')} and ${count} rows`); log('parse.end', `Parsed ${filepath} with columns and ${count} rows`);
}); });
// Create a new listener for the parse.error event // Create a new listener for the parse.error event
emitter.on('parse.error', ({ filepath, columns, error }) => { emitter.on('parse.error', ({ filepath, columns, error }) => {
log('parse.error', `Error parsing ${filepath} with columns ${columns.join(', ')}: ${error}`); log('parse.error', `Error parsing ${filepath} with columns: ${error}`);
}); });
// Create a new listener for the parse.data event // Create a new listener for the parse.data event
emitter.on('parse.data', ({ filepath, columns, data, index }) => { emitter.on('parse.data', ({ filepath, columns, data, index }) => {
log('parse.data', `Parsed ${filepath} with columns ${columns.join(', ')} at index ${index}`); log('parse.data', `Parsed ${filepath} with columns at index ${index}`);
}); });
Loading…
Cancel
Save