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

Custom logging #157

Closed
InanisOmnia opened this issue Apr 16, 2021 · 2 comments
Closed

Custom logging #157

InanisOmnia opened this issue Apr 16, 2021 · 2 comments

Comments

@InanisOmnia
Copy link

I think a great addition to this package would be the ability to map the logs to an external function

For example I used to use bettersqlite3 and this allowed you to pass a function when you setup the connection that will get called with the value of the logs. Options could include levels of logging such as errors, information or even as deep as debug which would log every single sql query run.

I dearly miss this feature when using mariadb.

Very rough example usage

const myLogger = {
    debug(msg) {
        console.log(`${new Date().toLocaleString()} ${msg}
    },
    error(msg) {
        console.log(`ERROR: ${new Date().toLocaleString()} ${msg}
    },
}

const conn = await mariadb.createConnection({
    host: "192.168.1.1",
    user: "user",
    password: "password",
    logger: {
        verbose: myLogger.debug // the raw sql of all sql queries
        error: myLogger.error // all errors
    }
});
@rusher
Copy link
Collaborator

rusher commented Jun 4, 2021

That would be a great addition, created https://jira.mariadb.org/browse/CONJS-167 for that.

@rusher
Copy link
Collaborator

rusher commented Sep 14, 2021

released in 3.0 version. (currently in beta for now)

@rusher rusher closed this as completed Sep 14, 2021
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

2 participants