From 7af4c7f6b8b73e3ce82dd35250d7aa311a363c4f Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Fri, 17 Sep 2021 16:27:44 +0100 Subject: [PATCH] build, deploy: Improve logging of image build messages Change-type: patch --- lib/utils/compose_ts.ts | 1 + lib/utils/logger.ts | 22 ++++++++++++++++++++++ npm-shrinkwrap.json | 6 +++--- package.json | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index 64b47b984e..afa740064f 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -1051,6 +1051,7 @@ export async function makeBuildTasks( infoStr = `build [${task.context}]`; } logger.logDebug(` ${task.serviceName}: ${infoStr}`); + task.logger = logger.getAdapter(); }); logger.logDebug( diff --git a/lib/utils/logger.ts b/lib/utils/logger.ts index c822ffe724..7aa69314f1 100644 --- a/lib/utils/logger.ts +++ b/lib/utils/logger.ts @@ -30,6 +30,14 @@ enum Level { LIVEPUSH = 'livepush', } +interface LoggerAdapter { + debug: (msg: string) => void; + error: (msg: string) => void; + info: (msg: string) => void; + log: (msg: string) => void; + warn: (msg: string) => void; +} + /** * General purpose logger class with support for log streams and colours. * Call `Logger.getLogger()` to retrieve a global shared instance of this @@ -57,6 +65,8 @@ class Logger { protected deferredLogMessages: Array<[string, Level]>; + protected adapter: LoggerAdapter; + protected constructor() { const logger = new StreamLogger(); const chalk = getChalk(); @@ -91,6 +101,14 @@ class Logger { this.formatMessage = logger.formatWithPrefix.bind(logger); this.deferredLogMessages = []; + + this.adapter = { + debug: (msg: string) => this.logDebug(msg), + error: (msg: string) => this.logError(msg), + info: (msg: string) => this.logInfo(msg), + log: (msg: string) => this.logLogs(msg), + warn: (msg: string) => this.logWarn(msg), + }; } protected static logger: Logger; @@ -151,6 +169,10 @@ class Logger { }); this.deferredLogMessages = []; } + + public getAdapter(): LoggerAdapter { + return this.adapter; + } } export = Logger; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2201466947..2cbcb8e719 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -15766,9 +15766,9 @@ } }, "resin-multibuild": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/resin-multibuild/-/resin-multibuild-4.12.1.tgz", - "integrity": "sha512-ORtzaDZGS5wftNo4KXi4yOcqSsjU0/56oY7mXlc8XcmqusOOfr1N3rnFpXkjQ7COJLcPvfPT+OEeJuQ7l7cOmg==", + "version": "4.12.2-logger-for-multiarch-warnings-277a26c5e7ea11c2c4bba007263f4c168232682d", + "resolved": "https://registry.npmjs.org/resin-multibuild/-/resin-multibuild-4.12.2-logger-for-multiarch-warnings-277a26c5e7ea11c2c4bba007263f4c168232682d.tgz", + "integrity": "sha512-jA1OuXpcuwtrVJB4gdS54r7O3htvHfUeqgjn2ZTf4tmhuJDloktAGAhyIl7iUA+gp6GV1dviV0UaXWWufsEuaA==", "requires": { "ajv": "^6.12.3", "bluebird": "^3.7.2", diff --git a/package.json b/package.json index 4f2a88c5f6..989ca5a17c 100644 --- a/package.json +++ b/package.json @@ -268,7 +268,7 @@ "resin-cli-visuals": "^1.8.0", "resin-compose-parse": "^2.1.3", "resin-doodles": "^0.1.1", - "resin-multibuild": "^4.12.1", + "resin-multibuild": "4.12.2-logger-for-multiarch-warnings-277a26c5e7ea11c2c4bba007263f4c168232682d", "resin-stream-logger": "^0.1.2", "rimraf": "^3.0.2", "semver": "^7.3.2",