Describe the bug
As an extender, I have noticed that some actions in the zowe-explorer-api break our logging approach. Specifically, the ZoweVsCodeExtension.updateCredentials() method. The method initializes a ProfilesCache if one is not provided as an argument. Inside of the ProfilesCache constructor, imperative.Logger.getAppLogger() is called which overrides the log4js configuration our extension provided.
Our extension uses log4js for logging, as does Zowe Explorer and imperative. They all run in the same memory space, and thus they all share the same log4js static memory. After calling ZoweVsCodeExtension.updateCredentials(), the log4js appenders our logger specified are replaced by imperative's. From that moment onwards, all log messages from our extension get outputted in the imperative log.
To Reproduce
I created a very simple sample extension (using the tutorial extension provided here as a starting point) that showcases this issue: https://github.com/benjamin-t-santos/zowe-explorer-testing/tree/log4js-issues
I provide instructions in the README, but all you have to do is:
- Clone the repository
- Run
npm install from the top-level directory to install log4js and zowe-explorer-api
- Launch a debug session using the "Run Extension" launch configuration. This will compile the extension and run it on a new host.
- Note the log messages: the first one ends up in the Debug console log, while the second one ends up in
imperative.log after the ZoweVsCodeExtension.updateCredentials() is made.
Expected behavior
The imperative logger does not modify the log4js static memory or affect extenders. This issue prevents us from being able to use these methods as extenders, as it breaks our logging. Disclaimer: I am not an expert on log4js so I'm not sure if it saying it is a static memory issue is entirely correct.
Providing our own instance of a ProfilesCache avoids this situation, but presents other issues with keeping credentials in sync.
Screenshots
Desktop (please complete the following information):
- OS: Mac
- Zowe Explorer Version: v3.1.2, but discovered on an earlier version
- (Optional) Zowe CLI Version:
- (Optional) Do you have secure credentials enabled?
- (Optional) Are you using a custom credential manager?
Additional context
Describe the bug
As an extender, I have noticed that some actions in the
zowe-explorer-apibreak our logging approach. Specifically, theZoweVsCodeExtension.updateCredentials()method. The method initializes aProfilesCacheif one is not provided as an argument. Inside of theProfilesCacheconstructor,imperative.Logger.getAppLogger()is called which overrides thelog4jsconfiguration our extension provided.Our extension uses
log4jsfor logging, as does Zowe Explorer and imperative. They all run in the same memory space, and thus they all share the samelog4jsstatic memory. After callingZoweVsCodeExtension.updateCredentials(), thelog4jsappenders our logger specified are replaced by imperative's. From that moment onwards, all log messages from our extension get outputted in theimperativelog.To Reproduce
I created a very simple sample extension (using the tutorial extension provided here as a starting point) that showcases this issue: https://github.com/benjamin-t-santos/zowe-explorer-testing/tree/log4js-issues
I provide instructions in the README, but all you have to do is:
npm installfrom the top-level directory to installlog4jsandzowe-explorer-apiimperative.logafter theZoweVsCodeExtension.updateCredentials()is made.Expected behavior
The
imperativelogger does not modify thelog4jsstatic memory or affect extenders. This issue prevents us from being able to use these methods as extenders, as it breaks our logging. Disclaimer: I am not an expert onlog4jsso I'm not sure if it saying it is a static memory issue is entirely correct.Providing our own instance of a
ProfilesCacheavoids this situation, but presents other issues with keeping credentials in sync.Screenshots
Desktop (please complete the following information):
Additional context