[CONJS-167] Custom logging Created: 2021-06-04  Updated: 2021-06-08  Resolved: 2021-06-08

Status: Closed
Project: MariaDB Connector/node.js
Component/s: configuration, other
Affects Version/s: None
Fix Version/s: 3.0.0-beta

Type: New Feature Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

see https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/157

Implement custom logging (log commands, trace, ...) would be a great addition.

There is different logger library like winston, debug, loglevel, ...
Driver must not required any of those logger as dependency, but provide API to permit using those, like :

const myLogger = {
    trace(msg) {
        console.log(`${new Date().toLocaleString()} ${msg}
    },
    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: {
        network: myLogger.trace // log all network exchanges
        query: myLogger.debug // the raw sql of all sql queries
        error: myLogger.error // all errors
    }
});


Generated at Thu Feb 08 03:23:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.