Skip to content

Commit

Permalink
Merge pull request #4071 from zowe/v3.x/zweLog
Browse files Browse the repository at this point in the history
V3: Use xplatform for logging
  • Loading branch information
MarkAckert authored Dec 2, 2024
2 parents 87f02f7 + 40e6254 commit 6476a4b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
All notable changes to the Zowe Installer will be documented in this file.

## `3.1.0`
- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#4071](https://github.com/zowe/zowe-install-packaging/pull/4071)
- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4064](https://github.com/zowe/zowe-install-packaging/pull/4064)
- Enhancement: command `zwe init` does not require NodeJS [#4088](https://github.com/zowe/zowe-install-packaging/pull/4088)
- Enhancement: command `zwe install` does not require NodeJS [#4069](https://github.com/zowe/zowe-install-packaging/pull/4069)
- Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994)
Expand Down
10 changes: 7 additions & 3 deletions bin/commands/init/certificate/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ elif [[ "${cert_type}" == JCE*KS ]]; then
keyring_option=2
fi
fi
# Trace or debug information will be part of the output, let's turn it off for the inline zwe commands
save_trace=$ZWE_PRIVATE_LOG_LEVEL_ZWELS
ZWE_PRIVATE_LOG_LEVEL_ZWELS=
# read keystore domains
cert_import_CAs=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',')
cert_import_CAs=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.importCertificateAuthorities" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }')
# read keystore domains
cert_domains=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.certificate.san" | tr '\n' ',')
cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.setup.certificate.san" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }')
if [ -z "${cert_domains}" ]; then
cert_domains=$(read_yaml_configmgr "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.externalDomains" | tr '\n' ',')
cert_domains=$(zwecli_inline_execute_command internal config get --config "${ZWE_CLI_PARAMETER_CONFIG}" --path ".zowe.externalDomains" | tr '\n' ',' | awk '{ print substr( $0, 1, length($0)-1 ) }')
fi
ZWE_PRIVATE_LOG_LEVEL_ZWELS=$save_trace

# read z/OSMF info
for item in user ca; do
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
1 change: 1 addition & 0 deletions build/zwe/types/@qjstypes/xplatform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function stringFromBytes(data:ArrayBuffer, offset:number, length:number,
*/
export function loadFileUTF8(path:string, sourceCCSID:number):string;
export function storeFileUTF8(path:string, targetCCSID:number, content:string):number;
export function appendFileUTF8(path: string, targetCCSID:number, content:string):number;

export var AUTO_DETECT:number;
export var NO_CONVERT:number;

0 comments on commit 6476a4b

Please sign in to comment.