diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index 3d689e1b78..534dcffb7f 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -14,7 +14,7 @@ const { version } = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT_DIR, 'pack * @param {HomeDir} homeDir * @returns {getBaseConfig} */ -export default function getBaseConfigFactory(homeDir) { +export default function getBaseConfigFactory() { const prereleaseTag = semver.prerelease(version) === null ? '' : `-${semver.prerelease(version)[0]}`; const dockerImageVersion = `${semver.major(version)}${prereleaseTag}`; @@ -134,12 +134,17 @@ export default function getBaseConfigFactory(homeDir) { }, }, log: { - file: { - categories: [], - path: homeDir.joinPath('logs', 'base', 'core.log'), + filePath: null, + debug: { + enabled: false, + ips: false, + sourceLocations: false, + threadNames: false, + timeMicros: false, + includeOnly: [], + exclude: [], }, }, - logIps: 0, indexes: [], }, platform: { diff --git a/packages/dashmate/configs/defaults/getMainnetConfigFactory.js b/packages/dashmate/configs/defaults/getMainnetConfigFactory.js index f4ed9aa785..0f83c4a7a1 100644 --- a/packages/dashmate/configs/defaults/getMainnetConfigFactory.js +++ b/packages/dashmate/configs/defaults/getMainnetConfigFactory.js @@ -26,13 +26,6 @@ export default function getMainnetConfigFactory(homeDir, getBaseConfig) { subnet: '172.26.24.0/24', }, }, - core: { - log: { - file: { - path: homeDir.joinPath('logs', 'mainnet', 'core.log'), - }, - }, - }, network: NETWORK_MAINNET, platform: { enable: false, diff --git a/packages/dashmate/configs/defaults/getTestnetConfigFactory.js b/packages/dashmate/configs/defaults/getTestnetConfigFactory.js index a818991202..a8aec0152b 100644 --- a/packages/dashmate/configs/defaults/getTestnetConfigFactory.js +++ b/packages/dashmate/configs/defaults/getTestnetConfigFactory.js @@ -30,11 +30,6 @@ export default function getTestnetConfigFactory(homeDir, getBaseConfig) { rpc: { port: 19998, }, - log: { - file: { - path: homeDir.joinPath('logs', 'testnet', 'core.log'), - }, - }, spork: { address: 'yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55', }, diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index a3bcf67897..6953fbfa07 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -853,11 +853,36 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) }); return configFile; }, - '1.3.0-dev.2': (configFile) => { + '1.3.0-dev.3': (configFile) => { Object.entries(configFile.configs) .forEach(([, options]) => { options.platform.drive.abci.docker.image = 'dashpay/drive:1-dev'; options.platform.dapi.api.docker.image = 'dashpay/dapi:1-dev'; + + // Update core log settings + options.core.log.filePath = null; + options.core.log.debug = { + enabled: false, + ips: !!options.core.logIps, + sourceLocations: false, + threadNames: false, + timeMicros: false, + includeOnly: [], + exclude: [], + }; + + // If debug log was enabled + if (options.core.log.file.categories.length > 0) { + options.core.log.filePath = options.core.log.file.path; + options.core.log.debug.enabled = true; + + if (!options.core.log.file.categories.includes('all')) { + options.core.log.debug.includeOnly = options.core.log.file.categories; + } + } + + delete options.core.log.file; + delete options.core.logIps; }); return configFile; }, diff --git a/packages/dashmate/docker-compose.yml b/packages/dashmate/docker-compose.yml index b267658716..3b2dfdbd94 100644 --- a/packages/dashmate/docker-compose.yml +++ b/packages/dashmate/docker-compose.yml @@ -29,7 +29,6 @@ services: volumes: - core_data:/home/dash - ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/core/dash.conf:/home/dash/.dashcore/dash.conf:ro - - ${CORE_LOG_DIRECTORY_PATH:?err}:/var/log/dash command: - dashd stop_grace_period: 30s @@ -112,7 +111,6 @@ services: volumes: - drive_tenderdash:/tenderdash - ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/platform/drive/tenderdash:/tenderdash/config:ro - - ${PLATFORM_DRIVE_TENDERDASH_LOG_DIRECTORY_PATH:?err}:/var/log/tenderdash stop_grace_period: 10s profiles: - platform diff --git a/packages/dashmate/src/config/configJsonSchema.js b/packages/dashmate/src/config/configJsonSchema.js index 0e9dc266d1..8da6b4ce48 100644 --- a/packages/dashmate/src/config/configJsonSchema.js +++ b/packages/dashmate/src/config/configJsonSchema.js @@ -401,36 +401,59 @@ export default { log: { type: 'object', properties: { - file: { + filePath: { + type: ['null', 'string'], + minLength: 1, + }, + debug: { type: 'object', properties: { - categories: { + enabled: { + type: 'boolean', + }, + ips: { + type: 'boolean', + }, + sourceLocations: { + type: 'boolean', + }, + threadNames: { + type: 'boolean', + }, + timeMicros: { + type: 'boolean', + }, + includeOnly: { type: 'array', uniqueItems: true, items: { type: 'string', - enum: ['all', 'net', 'tor', 'mempool', 'http', 'bench', 'zmq', 'walletdb', 'rpc', 'estimatefee', + enum: ['net', 'tor', 'mempool', 'http', 'bench', 'zmq', 'walletdb', 'rpc', 'estimatefee', 'addrman', 'selectcoins', 'reindex', 'cmpctblock', 'rand', 'prune', 'proxy', 'mempoolrej', 'libevent', 'coindb', 'qt', 'leveldb', 'chainlocks', 'gobject', 'instantsend', 'llmq', 'llmq-dkg', 'llmq-sigs', 'mnpayments', 'mnsync', 'coinjoin', 'spork', 'netconn', ], }, }, - path: { - type: 'string', - minLength: 1, + exclude: { + type: 'array', + uniqueItems: true, + items: { + type: 'string', + enum: ['net', 'tor', 'mempool', 'http', 'bench', 'zmq', 'walletdb', 'rpc', 'estimatefee', + 'addrman', 'selectcoins', 'reindex', 'cmpctblock', 'rand', 'prune', 'proxy', 'mempoolrej', + 'libevent', 'coindb', 'qt', 'leveldb', 'chainlocks', 'gobject', 'instantsend', 'llmq', + 'llmq-dkg', 'llmq-sigs', 'mnpayments', 'mnsync', 'coinjoin', 'spork', 'netconn', + ], + }, }, }, additionalProperties: false, - required: ['categories', 'path'], + required: ['enabled', 'ips', 'sourceLocations', 'threadNames', 'timeMicros', 'includeOnly', 'exclude'], }, }, additionalProperties: false, - required: ['file'], - }, - logIps: { - type: 'integer', - enum: [0, 1], + required: ['filePath', 'debug'], }, indexes: { type: ['array'], @@ -444,7 +467,7 @@ export default { }, }, required: ['docker', 'p2p', 'rpc', 'spork', 'masternode', 'miner', 'devnet', 'log', - 'logIps', 'indexes', 'insight'], + 'indexes', 'insight'], additionalProperties: false, }, platform: { diff --git a/packages/dashmate/src/config/generateEnvsFactory.js b/packages/dashmate/src/config/generateEnvsFactory.js index fcb0491ecf..781ef7bdaa 100644 --- a/packages/dashmate/src/config/generateEnvsFactory.js +++ b/packages/dashmate/src/config/generateEnvsFactory.js @@ -1,4 +1,3 @@ -import path from 'path'; import os from 'os'; import convertObjectToEnvs from './convertObjectToEnvs.js'; import { DASHMATE_HELPER_DOCKER_IMAGE } from '../constants.js'; @@ -20,7 +19,6 @@ export default function generateEnvsFactory(configFile, homeDir, getConfigProfil * COMPOSE_PROJECT_NAME: string, * COMPOSE_FILE: string, * COMPOSE_PATH_SEPARATOR: string, - * CORE_LOG_DIRECTORY_PATH: string * }} */ function generateEnvs(config) { @@ -69,13 +67,6 @@ export default function generateEnvsFactory(configFile, homeDir, getConfigProfil const { uid, gid } = os.userInfo(); - // Determine logs directory to mount into tenderdash container - let tenderdashLogDirectoryPath = homeDir.joinPath('logs', config.get('network')); - const tenderdashLogFilePath = config.get('platform.drive.tenderdash.log.path'); - if (tenderdashLogFilePath !== null) { - tenderdashLogDirectoryPath = path.dirname(tenderdashLogFilePath); - } - let driveAbciMetricsUrl = ''; if (config.get('platform.drive.abci.metrics.enabled')) { driveAbciMetricsUrl = 'http://0.0.0.0:29090'; @@ -92,11 +83,7 @@ export default function generateEnvsFactory(configFile, homeDir, getConfigProfil COMPOSE_PATH_SEPARATOR: ':', DOCKER_BUILDKIT: 1, COMPOSE_DOCKER_CLI_BUILD: 1, - CORE_LOG_DIRECTORY_PATH: path.dirname( - config.get('core.log.file.path'), - ), DASHMATE_HELPER_DOCKER_IMAGE, - PLATFORM_DRIVE_TENDERDASH_LOG_DIRECTORY_PATH: tenderdashLogDirectoryPath, PLATFORM_GATEWAY_RATE_LIMITER_METRICS_DISABLED: !config.get('platform.gateway.rateLimiter.metrics.enabled'), PLATFORM_DRIVE_ABCI_METRICS_URL: driveAbciMetricsUrl, ...convertObjectToEnvs(config.getOptions()), diff --git a/packages/dashmate/src/core/startCoreFactory.js b/packages/dashmate/src/core/startCoreFactory.js index 86401ee6df..3da7e54b8d 100644 --- a/packages/dashmate/src/core/startCoreFactory.js +++ b/packages/dashmate/src/core/startCoreFactory.js @@ -59,8 +59,10 @@ export default function startCoreFactory( coreCommand.push('--disablewallet=1'); } - const logFilePath = config.get('core.log.file.path'); - ensureFileMountExists(logFilePath, 0o666); + const logFilePath = config.get('core.log.filePath'); + if (logFilePath !== null) { + ensureFileMountExists(logFilePath, 0o666); + } const coreContainer = await dockerCompose.runService( config, diff --git a/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js b/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js index 5338eb4178..242f65582a 100644 --- a/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/setup/setupLocalPresetTaskFactory.js @@ -139,11 +139,8 @@ export default function setupLocalPresetTaskFactory( config.set('docker.network.subnet', subnet.join('.')); // Setup Core debug logs - const coreLogFilePath = homeDir.joinPath('logs', config.getName(), 'core.log'); - config.set('core.log.file.path', coreLogFilePath); - if (ctx.debugLogs) { - config.set('core.log.file.categories', ['all']); + config.set('core.log.debug.enabled', true); } // Although not all nodes are miners, all nodes should be aware of diff --git a/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js b/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js index b364bcf224..06bff9e7ed 100644 --- a/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js @@ -35,8 +35,10 @@ export default function startNodeTaskFactory( throw new Error(`'core.miner.enable' option only works with local network. Your network is ${config.get('network')}.`); } - const coreLogFilePath = config.get('core.log.file.path'); - ensureFileMountExists(coreLogFilePath, 0o666); + const coreLogFilePath = config.get('core.log.filePath'); + if (coreLogFilePath !== null) { + ensureFileMountExists(coreLogFilePath, 0o666); + } // Check Drive log files are created if (config.get('platform.enable')) { diff --git a/packages/dashmate/src/test/mock/getConfigMock.js b/packages/dashmate/src/test/mock/getConfigMock.js index 1961c48f28..641a1b8720 100644 --- a/packages/dashmate/src/test/mock/getConfigMock.js +++ b/packages/dashmate/src/test/mock/getConfigMock.js @@ -17,7 +17,6 @@ export default function getConfigMock(sinon) { configMock.get.withArgs('platform.drive.tenderdash.rpc.host').returns('127.0.0.1'); configMock.get.withArgs('platform.drive.tenderdash.rpc.port').returns('8103'); configMock.get.withArgs('platform.enable').returns(true); - configMock.get.withArgs('core.log.file.path').returns('/Users/user/.dashmate/logs/base/core.log'); return configMock; } diff --git a/packages/dashmate/templates/core/dash.conf.dot b/packages/dashmate/templates/core/dash.conf.dot index 807431f984..790575a9fb 100644 --- a/packages/dashmate/templates/core/dash.conf.dot +++ b/packages/dashmate/templates/core/dash.conf.dot @@ -3,14 +3,30 @@ daemon=0 # leave this set to 0 for Docker logtimestamps=1 maxconnections=256 reindex={{?it.reindex}}1{{??}}0{{?}} -{{~it.core.log.file.categories :category}} -{{? category === 'all'}} + +{{? it.core.log.debug.enabled }} +logips={{? it.core.log.debug.ips }}1{{??}}0{{?}} +logsourcelocations={{? it.core.log.debug.sourceLocations }}1{{??}}0{{?}} +logthreadnames={{? it.core.log.debug.threadNames }}1{{??}}0{{?}} +logtimemicros={{? it.core.log.debug.timeMicros }}1{{??}}0{{?}} + + {{? it.core.log.debug.includeOnly.length === 0 }} debug=1 + {{??}} + {{~it.core.log.debug.includeOnly :category}} +debug={{= category }} + {{~}} + {{?}} + {{~it.core.log.debug.exclude :category}} +debugexclude={{= category}} + {{~}} +{{?}} + +{{? it.core.log.filePath === null }} +nodebuglogfile=1 {{??}} -debug={{=category}}{{?}}{{~}} -debuglogfile=/var/log/dash/{{= it.core.log.file.path.split('/').pop() }} -logips={{=it.core.logIps }} -fallbackfee=0.00001 +debuglogfile=/var/log/dash/debug.log }} +{{?}} # JSON RPC server=1 diff --git a/packages/dashmate/templates/dynamic-compose.yml.dot b/packages/dashmate/templates/dynamic-compose.yml.dot index fbe122735e..6ed120930f 100644 --- a/packages/dashmate/templates/dynamic-compose.yml.dot +++ b/packages/dashmate/templates/dynamic-compose.yml.dot @@ -7,6 +7,10 @@ services: {{~ it.core.docker.commandArgs :arg }} - {{=arg}} {{~}} + {{? it.core.log.filePath !== null }} + volumes: + - {{=it.core.log.filePath}}:/var/log/dash/debug.log + {{?}} {{ driveLogs = Object.entries(it.platform.drive.abci.logs).filter(([, settings]) => settings.destination !== 'stderr' && settings.destination !== 'stdout'); }} {{? driveLogs.length > 0 }} @@ -18,6 +22,12 @@ services: {{~}} {{?}} + {{? it.platform.drive.tenderdash.log.path !== null }} + drive_tenderdash: + volumes: + - {{=it.platform.drive.tenderdash.log.path}}:/var/log/tenderdash/tenderdash.log + {{?}} + {{ gatewayLogs = it.platform.gateway.log.accessLogs.filter((l) => l.type === 'file'); }} {{? gatewayLogs.length > 0 }} gateway: diff --git a/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot b/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot index 9caf3e128b..a818a35640 100644 --- a/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot +++ b/packages/dashmate/templates/platform/drive/tenderdash/config.toml.dot @@ -54,7 +54,7 @@ db-dir = "data" log-level = "{{=it.platform.drive.tenderdash.log.level}}" # Path to the log file. This parameter is an additional option to the existing stderr output -{{? it.platform.drive.tenderdash.log.path }}log-file-path = "/var/log/tenderdash/{{= it.platform.drive.tenderdash.log.path.split('/').pop() }}"{{?}} +{{? it.platform.drive.tenderdash.log.path }}log-file-path = "/var/log/tenderdash/tenderdash.log"{{?}} # Output format: 'plain' (colored text) or 'json' log-format = "{{=it.platform.drive.tenderdash.log.format}}"