You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor the logic in CLI's logger to use log4js methods only - currently we have some methods that use `console.log`, others use `process.stdout`, `process.stderr`, etc.
Also, there are some methods that apply console colorization for the message, but in fact CLI may be used as a library or in CI, where these colorization does not make sense.
To resolve this, introduce a new appender and new layout that CLI will pass to `log4js`.
The appender (called `cli-appender`) will control if the message will be shown on `stdout` or `stderr`.
The layout (called `cli-layout`) will control the presentation of the message on the terminal, i.e. if we should add new line at the end of the message, if we should wrap it in borders (with `*` symbols, etc.) and the colorization of the message.
The layout will be applied on all methods, so you can use it with any log4js method, i.e. you can do:
```TypeScript
this.$logger.warn("This is my message", { useStderr: true });
this.$logger.info("This is my message", { useStderr: true });
```
Before passing the data to `log4js`, CLI will set required properties in the context of the logging event, so the appender and the layout can read them.
This way, in case CLI is used as a library, the custom properties and CLI specific layout, will not be shown.
Also delete some methods from logger API, so it is streamlined. Also change logger.error to print on stderr instead of stdout.
Move logger.ts to logger directory, so all logger logic will be on a single place.
0 commit comments