[CONJS-265] permit configuration of console warning message to be exported Created: 2023-09-04  Updated: 2023-09-08  Resolved: 2023-09-04

Status: Closed
Project: MariaDB Connector/node.js
Component/s: configuration
Affects Version/s: None
Fix Version/s: 3.2.1

Type: Task 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/249
`logger` configuration permit to log error/query/network messages, but there is still some remaining messages that are send to console.

Those are configuration warnings and pool leaking warnings.
Goal is to provided a solution to permit external logging for those warnings.



 Comments   
Comment by Diego Dupin [ 2023-09-08 ]

If no warning logger is set, those warning will still be written on console.

Here is an example of use :

const mariadb = require('mariadb');
const winston = require('winston');
 
const logger = winston.createLogger({
  level: 'info',
  transports: [
    // - Write all logs with level `error` and below to `error.log`
    // - Write all logs with level `info` and below to `combined.log`
    new winston.transports.Console({ filename: 'error.log', level: 'error' }),
    new winston.transports.Console({ filename: 'combined.log' })
  ]
});
 
const pool = mariadb.createPool({
  host: 'mydb.com',
  user:'myUser',
  password: 'myPwd',
  logger: {
    network: (msg) => logger.silly(msg),
    query: (msg) => logger.info(msg),
    error: (err) => logger.error(err),
    warning: (msg) => logger.warn(msg),
  }
});

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