rwjblue / codemod-cli

MIT License
89 stars 34 forks source link

Add logger #82

Open ctjhoa opened 4 years ago

ctjhoa commented 4 years ago

Newly generate codemod doesn't come with logger. I dug into ember-codemods, looking for a standard way to log errors and warnings.

I found several ways to achieve it:

  1. Use pure nodejs https://github.com/ember-codemods/ember-data-codemod/blob/master/transforms/globals-to-ember-data-imports/index.js#L6

  2. Use winston https://github.com/ember-codemods/ember-angle-brackets-codemod/blob/master/lib/logger.js

  3. Use console https://github.com/ember-codemods/ember-component-template-colocation-migrator/blob/master/lib/utils/file.js#L8

  4. Use console with SilentError pattern https://github.com/ember-codemods/tagless-ember-components-codemod/commit/491cfa20d403fea047882989f07d23844b2b231d

What's your recommendation on this? Do you think a default logger should be generate too?

rwjblue commented 4 years ago

Ya, I was actually just chatting a bit with @mmun on this the other day. Hopefully he has a chance to chime in...

mmun commented 4 years ago

What I was thinking about is a way to collect data across multiple files and do some global linting/reporting based on that. That might be more than what most people are wanting here.