Skip to content

Streamline CLI's logger #4602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rosen-vladimirov opened this issue May 9, 2019 · 1 comment
Closed

Streamline CLI's logger #4602

rosen-vladimirov opened this issue May 9, 2019 · 1 comment
Assignees
Milestone

Comments

@rosen-vladimirov
Copy link
Contributor

Is your feature request related to a problem? Please describe.
CLI's logger has different ways and methods to write output to the console:

  • using log4js in some cases
  • using console.log
  • using process.stdout.write
  • using process.stderr.write

This makes it difficult to determine which method should be used.

Also logger.error method prints to stdout, instead of printing to stderr.

Describe the solution you'd like
The idea is to use only log4js internally and pass data to it. Use appenders and layouts to format and print the messages.
This will allow using different appender when CLI is used as a command line and as a library.

Describe alternatives you've considered
Drop log4js and format the messages in CLI only. Handle levels and categories directly in CLI.

@rosen-vladimirov
Copy link
Contributor Author

rosen-vladimirov commented May 9, 2019

Additional code changes

  • remove printMsgWithTimeout method from logger - it was used only in progress-indicator
  • remove warnWithLabel method from logger - it has been used on only two places and did not make sense to keep it.
  • deprecateout method from logger - its usage is replaced with logger.info
  • deprecatewrite method from logger - its intention was to print message on stdout, without modifying it (i.e. without adding new line, etc.), so replace it with info method and passing skipNewLine to true:
// OLD:
this.logger.write(line, platform, deviceIdentifier);
// NEW:
this.logger.info(line, platform, deviceIdentifier, { [LoggerConfigData.skipNewLine]: true });
  • deprecate printInfoMessageOnSameLine method from logger - it was used to print messages on stdout without adding new line and only when log level is info. However, the implementation was incorrect (i.e. it was not checking the log level correctly). Replace the method with logger.info calls:
// OLD:
this.$logger.printInfoMessageOnSameLine("Waiting for emulator device initialization...");
// NEW:
this.$logger.info("Waiting for emulator device initialization...", { [LoggerConfigData.skipNewLine]: true });
  • change logger.error to print to stderr instead of stdout.
  • deprecate printOnStderr method from logger. This can be achieve with any log level by passing useStderr: true. Usage is replaced with logger.error.
  • move all logger related files in a logger directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants