webpack-content-replacer-plugin icon indicating copy to clipboard operation
webpack-content-replacer-plugin copied to clipboard

Add exception levels

Open iGitScor opened this issue 8 years ago • 11 comments

Hi,

this plugin should have several exception levels

Exceptions

When an exception is caught, all the webpack build failed. It should be nice if we could configure this behavior

Exception level

  • Strict: actual behavior. If the plugin fails, the webpack build crashes
  • None: no exception are caught and only a warning message is displayed in the console (if the silent mode is not activated)
  • Log: log errors in a log file (and also display a warning message like the none level)

Not forgive to add test

Thank you

iGitScor avatar Mar 04 '17 10:03 iGitScor

Hi @iGitScor. I can take this work if no one else is currently working on it. I'll do some research first and discuss with you about the approach to do it. Thanks

YQBird avatar Mar 10 '17 17:03 YQBird

Hi @YQBird,

Nobody has started working on it, so yes you can take this. If you need help, please ask me 😉

Thank you

iGitScor avatar Mar 11 '17 10:03 iGitScor

@iGitScor. My understanding here is that if plugin fails, the webpack build will still work in None & Log level. Only warning or log file is created. Is this correct?

YQBird avatar Mar 11 '17 15:03 YQBird

Yes, that's correct. The main complexity will be to handle rights to write logs.

In the future we'll can potentially add clean log feature.

iGitScor avatar Mar 11 '17 18:03 iGitScor

Hi @iGitScor. I'm thinking two approach here. The first one is to use process global object to catch the uncaught exception. When this event happens, a callback will be called to log or write log to file. The second one is to integrate with winston npm module, depending on the exception level, different logger will be create. we can use some built-in function from this module and add log level. Which one do you think is a better approach?

YQBird avatar Mar 13 '17 19:03 YQBird

Hi,

I briefly read the documentation of Winston package and it seems to fit our need and the package is enough mature to be integrated. I am not 100% sure but I would choose for the second solution. We'll see by the usage of it if it can be kept.

iGitScor avatar Mar 14 '17 09:03 iGitScor

Hi. I personally prefer second approach as well. I'll start to work on that.

YQBird avatar Mar 14 '17 13:03 YQBird

hi @iGitScor. Being really busy recently. I did some attempt to get exception level from constructor but find it's very difficult to get that argument and use it. I'm think to config exception level as a process.env variable, then use this variable in the core file. Any advice here ?

YQBird avatar Mar 23 '17 18:03 YQBird

Hi,

I did some attempt to get exception level from constructor but find it's very difficult to get that argument and use it

do not hesitate to share gist to illustrate your difficulties.

I was thinking of this approach

iGitScor avatar Mar 24 '17 09:03 iGitScor

Hi @iGitScor, here is what I have tried with this issue. https://github.com/YQBird/webpack-content-replacer-plugin/tree/add_exception_level. But I don't find a way to properly setting the log and do the testing yet. I am thinking if it is overkill to use winston for this issue. I will try to use NodeJS process object to solve this. Will keep you update.

YQBird avatar Mar 26 '17 18:03 YQBird

Hi @YQBird,

what do you mean ?

I don't find a way to properly setting the log

iGitScor avatar Mar 31 '17 09:03 iGitScor