diff --git a/src/config/config.js b/src/config/config.js index 9fbfeabf..7a605ca2 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -2,18 +2,29 @@ import { getConfig } from '../utils/config-loader'; import { getDataModelVersion } from '../utils/helpers'; import { getChiaRoot } from '../utils/chia-root.js'; import { logger } from './logger.js'; +import { createHash } from 'crypto'; const chiaRoot = getChiaRoot(); const persistanceFolder = `${chiaRoot}/cadt/${getDataModelVersion()}`; +const localQueryLogger = (query) => { + const queryString = query.split(/:\s(.+)/)[1]; + const queryHash = createHash('md5').update(queryString).digest('hex'); + logger.debug(`SQLite Sequelize [query hash: ${queryHash}]\n\t${query}`); +}; + +const mirrorQueryLogger = (query) => { + const queryString = query.split(/:\s(.+)/)[1]; + const queryHash = createHash('md5').update(queryString).digest('hex'); + logger.debug(`Mirror DB Sequelize [query hash: ${queryHash}]\n\t${query}`); +}; + const appLogLevel = getConfig().APP.LOG_LEVEL; const localLogging = - appLogLevel === 'silly' || appLogLevel === 'debug' - ? (query) => logger.debug(`SQLite Sequelize ${query}`) - : false; + appLogLevel === 'silly' || appLogLevel === 'debug' ? localQueryLogger : false; const mirrorLogging = appLogLevel === 'silly' || appLogLevel === 'debug' - ? (query) => logger.debug(`Mirror DB Sequelize ${query}`) + ? mirrorQueryLogger : false; export default {