dstore icon indicating copy to clipboard operation
dstore copied to clipboard

Customizable error logging

Open xmedeko opened this issue 4 years ago • 0 comments

Following discussion in #234 I propose a very simple customizable (error) logging. Instead of hard coding console.error(err), define the global logging API with the default implementation, e.g.

const dstoreLog = {
    exception(err) { console.error(err); }
    // ... other functions
}

then exchange all console.error(err) for dstoreLog.exception(err). Everything work backward compatible. But a library user may easily plug in own handler, e.g.

dstoreLog.exception = (err) => {
    // some custom code for error reporting
}

And that's all, very simple and no external dependencies.

Note: I have not a big experience with JS, but this pattern is used in C# libraries very often.

xmedeko avatar Mar 01 '20 21:03 xmedeko