migrate-mongo icon indicating copy to clipboard operation
migrate-mongo copied to clipboard

Add possibility to perform custom code on certain events

Open timschlechter opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. I would like to write logs when certain things happen, for example a migration script started, completed or failed.

Describe the solution you'd like Add handlers in the migratie-mongo-config which are used when these events happen. For example:

const config = {
  ...,
  onMigrationStarted: (filename) => { console.log(`Migration ${filename) started`); },
  onMigrationCompleted: (filename, err) => { 
    if (err) {
      console.log(`Migration ${filename) failed: ${err.message}`); },
    } else {
      console.log(`Migration ${filename) completed successfully`); },
    }    
};

Additional context Would you consider having something like this in this package? If so, I can prepare a PR where this is implemented. Feedback and/or alternative solutions are also very appreciated.

timschlechter avatar Jan 14 '21 08:01 timschlechter

pretty useful also because it allows to use the logging library of our choice

nhuray avatar Sep 15 '21 22:09 nhuray