Skip to content

Commit

Permalink
Merge pull request #4068 from zowe/v2.x/zweLog
Browse files Browse the repository at this point in the history
V2: Use xplatform for logging
  • Loading branch information
MarkAckert authored Nov 5, 2024
2 parents 43bf171 + e1c869a commit 62e3828
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to the Zowe Installer will be documented in this file.
<!--Add the PR or issue number to the entry if available.-->

## `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. [#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)

## `2.17.0`
Expand Down
33 changes: 9 additions & 24 deletions bin/libs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 62e3828

Please sign in to comment.