1.0.0 • Published 7 years ago

log4js-protractor-appender-file v1.0.0

Weekly downloads
126
License
-
Repository
github
Last release
7 years ago

log4js-protractor-appender-file

Build Status npm

Log4js appender file suited for Protractor

What is it for?

Log4js is a very powerful tool to provide logs in a NodeJS application and/or test suite. Unfortunately, it poorly integrates with Protractor, as the latter uses a "control flow" system that runs tasks in a very particular order.

log4js-protractor-appender-file ensures logging is integrated with the control flow, and display logging in the proper order.

Example:

logger.info('Navigating to /');
browser.get('/');
element(by.css('#someText')).getText().then(function (text) {
  logger.info('Displayed text is: ', text);
});
logger.info('Should be displayed last');

Outputs without log4js-protractor-appender-file:

[INFO] Navigating to /
[INFO] Should be displayed last
[INFO] Displayed text is: Some text

Outputs with log4js-protractor-appender-file:

[INFO] Navigating to /
[INFO] Displayed text is: Some Text
[INFO] Should be displayed last

Promises

It resolves promises passed as arguments before outputting them.

Example:

logger.info('Displayed text is:', element(by.css('#someText')).getText());

Outputs without log4js-protractor-appender-file:

[INFO] Displayed text is: [Promise object]

Outputs with log4js-protractor-appender-file:

[INFO] Displayed text is: Some Text

Setup

log4js-protractor-appender-file overrides log4js' default console appender. Just install it as a dependency:

$ npm install log4js-protractor-appender-file --save

Then you can load it as any file appender. For example:

{
  "appenders": [
    {
      "type": "log4js-protractor-appender-file"
    }
  ]
}