diff --git a/CHANGES b/CHANGES index f39c88cf9..8be651529 100644 --- a/CHANGES +++ b/CHANGES @@ -2410,4 +2410,5 @@ * Update node to 16.13.1 * mongodb: update to 4.4 * Add `upstreamVersion` to manifest +* Add `logPaths` to manifest diff --git a/src/apps.js b/src/apps.js index 33b8c3bc5..b297ad7e2 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1797,11 +1797,27 @@ async function getLogPaths(app) { const appId = app.id; - var filePaths = []; + const filePaths = []; filePaths.push(path.join(paths.LOG_DIR, appId, 'apptask.log')); filePaths.push(path.join(paths.LOG_DIR, appId, 'app.log')); if (app.manifest.addons && app.manifest.addons.redis) filePaths.push(path.join(paths.LOG_DIR, `redis-${appId}/app.log`)); + if (app.manifest.logPaths) { + const [error, result] = await safe(docker.inspect(app.containerId)); + if (!error) { + const runVolume = result.Mounts.find(function (mount) { return mount.Destination === '/run'; }); + const tmpVolume = result.Mounts.find(function (mount) { return mount.Destination === '/tmp'; }); + const dataVolume = result.Mounts.find(function (mount) { return mount.Destination === '/app/data'; }); + + // note: wild cards are not supported yet in logPaths since that will require shell expansion + for (const logPath of app.manifest.logPaths) { + if (logPath.startsWith('/tmp/')) filePaths.push(`${tmpVolume.Source}/${logPath.slice('/tmp/'.length)}`); + else if (logPath.startsWith('/run/')) filePaths.push(`${runVolume.Source}/${logPath.slice('/run/'.length)}`); + else if (logPath.startsWith('/app/data/')) filePaths.push(`${dataVolume.Source}/${logPath.slice('/app/data/'.length)}`); + } + } + } + return filePaths; }