Skip to content

Customizable error logging #239

@xmedeko

Description

@xmedeko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions