diff --git a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts index af153664455..1c1e39b52c9 100644 --- a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts +++ b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts @@ -23,6 +23,7 @@ import { Logger, LogLevelDesc, LoggerProvider, + Bools, } from "@hyperledger/cactus-common"; /* @@ -34,6 +35,7 @@ export interface IFabricTestLedgerV1ConstructorOptions { imageName?: string; envVars?: Map; logLevel?: LogLevelDesc; + emitContainerLogs?: boolean; } /* @@ -70,6 +72,7 @@ export class FabricTestLedgerV1 implements ITestLedger { public readonly imageVersion: string; public readonly imageName: string; public readonly publishAllPorts: boolean; + public readonly emitContainerLogs: boolean; public readonly envVars: Map; private readonly log: Logger; @@ -77,7 +80,7 @@ export class FabricTestLedgerV1 implements ITestLedger { private container: Container | undefined; private containerId: string | undefined; - public get className() { + public get className(): string { return FabricTestLedgerV1.CLASS_NAME; } @@ -92,6 +95,9 @@ export class FabricTestLedgerV1 implements ITestLedger { this.imageVersion = options.imageVersion || DEFAULT_OPTS.imageVersion; this.imageName = options.imageName || DEFAULT_OPTS.imageName; this.publishAllPorts = options.publishAllPorts; + this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs) + ? (options.emitContainerLogs as boolean) + : true; this.envVars = options.envVars || DEFAULT_OPTS.envVars; if (compareVersions.compare(this.getFabricVersion(), "1.4", "<")) @@ -420,6 +426,16 @@ export class FabricTestLedgerV1 implements ITestLedger { eventEmitter.once("start", async (container: Container) => { this.container = container; this.containerId = container.id; + + if (this.emitContainerLogs) { + const logOptions = { follow: true, stderr: true, stdout: true }; + const logStream = await container.logs(logOptions); + logStream.on("data", (data: Buffer) => { + const fnTag = `[${this.getContainerImageName()}]`; + this.log.debug(`${fnTag} %o`, data.toString("utf-8")); + }); + } + try { await this.waitForHealthCheck(); resolve(container); diff --git a/tools/docker/fabric-all-in-one/supervisord.conf b/tools/docker/fabric-all-in-one/supervisord.conf index 811a873c72e..8a518657162 100644 --- a/tools/docker/fabric-all-in-one/supervisord.conf +++ b/tools/docker/fabric-all-in-one/supervisord.conf @@ -2,28 +2,34 @@ logfile = /var/log/supervisord.log logfile_maxbytes = 50MB logfile_backups=10 -loglevel = info +loglevel = debug [program:sshd] -command=/usr/sbin/sshd -D +command=/usr/sbin/sshd -D -dd autostart=true autorestart=true -stderr_logfile=/var/log/sshd.err.log -stdout_logfile=/var/log/sshd.out.log +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 [program:dockerd] command=dockerd-entrypoint.sh autostart=true autorestart=true -stderr_logfile=/var/log/dockerd.err.log -stdout_logfile=/var/log/dockerd.out.log +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 [program:fabric-network] command=/run-fabric-network.sh autostart=true autorestart=unexpected -stderr_logfile=/var/log/fabric-network.err.log -stdout_logfile=/var/log/fabric-network.out.log +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 [inet_http_server] port = 0.0.0.0:9001