Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable error logging #239

Open
xmedeko opened this issue Mar 1, 2020 · 0 comments
Open

Customizable error logging #239

xmedeko opened this issue Mar 1, 2020 · 0 comments

Comments

@xmedeko
Copy link

xmedeko commented Mar 1, 2020

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 xmedeko changed the title Use customizable error logging Customizable error logging Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant