From c5aea42ba51bb6a195d3a157a67bc6fba0e989cd Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Tue, 5 Nov 2024 13:21:35 +0100 Subject: [PATCH 1/2] Use xplatform for logging Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 3 ++- bin/libs/common.ts | 33 +++++++++------------------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d76a381ddc..ad7f0afd6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to the Zowe Installer will be documented in this file. ## `2.18.1` -- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4063](https://github.com/zowe/zowe-install-packaging/pull/4063) - Bugfix: Error message `ZWEL0141E` did not print user ID. [#3971](https://github.com/zowe/zowe-install-packaging/pull/3971) ## `2.17.0` diff --git a/bin/libs/common.ts b/bin/libs/common.ts index 7eabf33f5f..bee6a059f4 100644 --- a/bin/libs/common.ts +++ b/bin/libs/common.ts @@ -128,36 +128,21 @@ export function date(...args: string[]): string|undefined { let logExists = false; -let logFile:std.File|null = null; function writeLog(message: string): boolean { + const filename = std.getenv('ZWE_PRIVATE_LOG_FILE'); + if (!filename) { + return false; + } + logExists = fs.fileExists(filename); if (!logExists) { - const filename = std.getenv('ZWE_PRIVATE_LOG_FILE'); - if (filename) { + fs.createFile(filename, 0o640, message); logExists = fs.fileExists(filename); - if (!logExists) { - fs.createFile(filename, 0o640, message); - logExists = fs.fileExists(filename); - } - if (logExists) { - let errObj = {errno:undefined}; - logFile = std.open(filename, 'w', errObj); - if (errObj.errno) { - printError(`Error opening file ${filename}, errno=${errObj.errno}`); - logFile=null; - logExists=false; - return false; - } - } - } - } - if (logFile===undefined || logFile===null) { - return false; } else { - //TODO this does utf8. should we flip it to 1047 on zos? - logFile.puts(message); - return true; + xplatform.appendFileUTF8(filename, xplatform.AUTO_DETECT, message); + return true; } + return logExists; } From beff0053c4ee169484a8a5292d2e9fec0971aa86 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Tue, 5 Nov 2024 13:25:12 +0100 Subject: [PATCH 2/2] Changelog update Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7f0afd6c..950cf6954c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe Installer will be documented in this file. ## `2.18.1` -- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#4068](https://github.com/zowe/zowe-install-packaging/pull/4068) - Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4063](https://github.com/zowe/zowe-install-packaging/pull/4063) - Bugfix: Error message `ZWEL0141E` did not print user ID. [#3971](https://github.com/zowe/zowe-install-packaging/pull/3971)