function Logger(options, eventHandler) {
        var _this = this;

        (0, _classCallCheck3.default)(this, Logger);

        /**
         * log level
         * silent : no logs
         * command : command only
         * result : result only
         * error : error only
         * verbose : command + data + result
         */
        this.logLevel = options.logLevel;

        this.setupWriteStream(options);

        /**
         * disable colors if coloredLogs is set to false or if we pipe output into files
         */
        if (!JSON.parse(process.env.WEBDRIVERIO_COLORED_LOGS) || this.writeStream) {
            (0, _keys2.default)(_constants.COLORS).forEach(function (colorName) {
                _constants.COLORS[colorName] = '';
            });
        }

        // register event handler to log command events
        eventHandler.on('command', function (data) {
            if (_this.logLevel === 'command' || _this.logLevel === 'verbose') {
                _this.command(data.method, data.uri.path);
            }
            if (_this.logLevel === 'data' || _this.logLevel === 'verbose') {
                _this.data(data.data);
            }
        });

        eventHandler.on('info', function (msg) {
            if (_this.logLevel === 'verbose') {
                _this.info(msg);
            }
        });

        // register event handler to log result events
        eventHandler.on('result', function (data) {
            // only log result events if they got executed successfully
            if (data.body && data.body.value && (_this.logLevel === 'result' || _this.logLevel === 'verbose')) {
                _this.result(data.body.value ? data.body.value : data.body.orgStatusMessage);
            }
        });

        // register event handler to log error events
        eventHandler.on('error', function (data) {
            if (data.err && data.err.code === 'ECONNREFUSED') {
                _this.error(`Couldn't find a running selenium server instance on ${data.requestOptions.uri}`);
            } else if (data.err && data.err.code === 'ENOTFOUND') {
                _this.error(`Couldn't resolve hostname ${data.requestOptions.uri}`);
            } else if (data.err && data.err.code === 'NOSESSIONID') {
                _this.error(`Couldn't get a session ID - ${data.err.message}`);
            } else if (_this.logLevel === 'error' || _this.logLevel === 'verbose') {
                if (data.body && _constants.ERROR_CODES[data.body.status]) {
                    _this.error(_constants.ERROR_CODES[data.body.status].id + '\t' + _constants.ERROR_CODES[data.body.status].message + '\n\t\t\t' + data.body.value.message);
                } else if (typeof data.message === 'string') {
                    _this.error('ServerError\t' + data.message);
                } else {
                    _this.error(_constants.ERROR_CODES['-1'].id + '\t' + _constants.ERROR_CODES['-1'].message);
                }
            }
        });
    }
Logger module

A Logger helper with fancy colors