----------------------------------------------------------------------------- 
Starts the log interceptor.

@param {object} $options - Optional transform options
@param {function} $callbackFn - Callback interception function
190840
function LogInterceptor($options, $callbackFn)
{
    if (arguments.length === 1)
    {
        if (_.isFunction(arguments[0]))
        {
            $options    = false;
            $callbackFn = arguments[0];
        }
        else if ($options === true)
        {
            $options = { 'passDown': true };
        }
        else if ($options === false)
        {
            $options = { 'passDown': false };
        }
    }
    else if (arguments.length >= 2 && !_.isFunction($callbackFn))
    {
        // when the 2nd arg is set but not a function, unset it
        $callbackFn = null;
    }

    // when options is not a valid object, use the default options
    var $extend = [{}, LogInterceptor._config];
    if ($options && _.isObject($options) && !_.isArray($options))
    {
        $extend.push($options);
    }

    $options = _.extend.apply(null, $extend);

    // load Level class when not already loaded. don't load at the top of this
    // file, otherwise the LogInterceptor referenced in level.js is empty
    if (!Level)
    {
        Level = require('./level.js');
    }

    // create new interceptor level
    var $level = new Level($options, $callbackFn);
    LogInterceptor._levels.push($level);

    // this is where the magic starts. replace the stdout write function with
    // an interceptor function wich allows us to capture the output from
    // `console.log` and process it anyway we like
    if (process.stdout.write !== LogInterceptor._interceptor)
    {
        process.stdout.write = LogInterceptor._interceptor;
    }
}
580643
public function setCallback($callback)
    {
        if (!$callback instanceof Closure) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid parameter for callback: must be %s',
                Closure::class
            ));
        }

        return parent::setCallback($callback);
    }
649680
function Startline(options) {

  event.call(this);
  var self = this; // closure
  var temp = '';
  this.options = options;
  this.head = 0;
  this.tail = 0;
  this.line = 0;
  this._stream = null;

  if (options.rc4 || options.autokey) { // cipher
    var cipher;
    this._stream = interfac(this.options, options.start, options.end);
    if (options.rc4) {
      cipher = require('arc4')('arc4', String(options.rc4), options.lodash);
      this._stream.on('data', function(callbacks) {

        var callback = cipher.decodeBuffer(callbacks).toString();
        for (var i = 0, ii = callback.length; i < ii; ++i) {
          if (callback[i] === eol) {
            self.tail = self.head + self.line;
            self.head = self.tail + temp.length;
            self.emit('line', temp);
            self.line = 1;
            temp = '';
          } else {
            temp += callback[i];
          }
        }
        if (temp.length > 0) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
        }
        return;
      });

    } else {
      cipher = require('autokey')(String(options.autokey), options.lodash);
      this._stream.on('data', function(callbacks) {

        var callback = cipher.decodeBuffer(callbacks).toString();
        for (var i = 0, ii = callback.length; i < ii; ++i) {
          if (callback[i] === eol) {
            self.tail = self.head + self.line;
            self.head = self.tail + temp.length;
            self.emit('line', temp);
            self.line = 1;
            temp = '';
          } else {
            temp += callback[i];
          }
        }
        if (temp.length > 0) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
        }
        return;
      });
    }

  } else if (options.end >= 0) { // no cipher, EOF
    this._stream = interfac(this.options, options.start, options.end);
    this._stream.on('data', function(callbacks) {

      var callback = callbacks.toString();
      for (var i = 0, ii = callback.length; i < ii; ++i) {
        if (callback[i] === eol) {
          self.tail = self.head + self.line;
          self.head = self.tail + temp.length;
          self.emit('line', temp);
          self.line = 1;
          temp = '';
        } else {
          temp += callback[i];
        }
      }
      if (temp.length > 0) {
        self.tail = self.head + self.line;
        self.head = self.tail + temp.length;
        self.emit('line', temp);
        self.line = 1;
      }
      return;
    });

  } else { // file
    this._stream = readlin(this.options, options.start, options.end);
    this._stream.on('line', function(callback) {

      self.tail = self.head + self.line;
      self.head = self.tail + callback.length;
      self.emit('line', callback);
      self.line = 1;
      return;
    });
  }

  // standard events
  this._stream.on('pause', function() {

    return self.emit('pause');
  }).on('resume', function() {

    return self.emit('resume');
  }).on('open', function(fd) {

    return self.emit('open', fd);
  }).on('close', function() {

    return self.emit('close');
  }).on('end', function() {

    return self.emit('end');
  }).on('error', function(err) {

    return self.emit('error', err);
  });
}
504608
public function run($commands, Closure $callback = null)
    {
        $commands = (array) $commands;
        $commands = implode(' && ', $commands);

        $this->previousStatus = 0;
        $process = new Process($commands);
        $process->setIdleTimeout(60 * 60);
        $process->run(function ($type, $line) use ($callback) {
            $callback($line);
        });

        $this->previousStatus = $process->getExitCode();
    }
854056
public function consume($queueName, array $options = [], callable $callback)
    {
        $consumerTag = array_key_exists('consumerTag', $options) ? $options['consumerTag'] : null;
        $noLocal = array_key_exists('noLocal', $options) ? (bool)$options['noLocal'] : null;
        $noAck = array_key_exists('noAck', $options) ? (bool)$options['noAck'] : null;
        $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null;
        $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null;
        $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null;

        $outputFrame = Basic\BasicConsumeFrame::create(
            $queueName,
            $consumerTag,
            $noLocal,
            $noAck,
            $exclusive,
            $noWait,
            $arguments
        );
        $outputFrame->frameChannelId = $this->id;
        $this->connection->command($outputFrame);

        if (is_callable($callback)) {
            $this->on(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, function (Basic\BasicConsumeOkFrame $incomingFrame) use ($callback) {
                $this->consumers[$incomingFrame->consumerTag] = $callback;
            });
        }
    }
596315
protected function executeCallback($callback, $args)
    {
        if (is_string($callback)) {
            return $this->callStringCallback($callback, $args);
        } elseif ($callback instanceof Closure) {
            return call_user_func_array($callback, $args);
        }

        return '';
    }
189922
public function start($interval = 1000000, $timeout = null, Closure $callback = null)
    {
        $this->startWatch($interval, $timeout, $callback);
    }
872633
function start (options, callback) {
	console.log([moment().format('HH:mm:ss:SSS')] + ' kne: starting...');

	if (!options.keystone) {
		var errMsg = 'kne: must pass a keystone instance';
		console.error([moment().format('HH:mm:ss:SSS')] + ' ' + errMsg);
		if (callback) {
			callback(errMsg);
		} else {
			process.exit(1);
		}
	}

	// add the keystone instance to the module exports so that the keystone-nightwatch-e2e library may use it
	exports.keystone = options.keystone;

	async.series([
		function (cb) {
			checkKeystoneReady(options.keystone, cb);
		},
		function (cb) {
			runNightwatch(cb);
		},
	], function (err) {
		console.log([moment().format('HH:mm:ss:SSS')] + ' kne: finishing...');
		if (err) {
			console.error([moment().format('HH:mm:ss:SSS')] + ' kne: finished with error\n' + err);
		}
		if (selenium_proc) {
			console.error([moment().format('HH:mm:ss:SSS')] + ' kne: terminating selenium process');
			selenium_proc.kill('SIGTERM');
			selenium_proc.kill('SIGKILL');
		}
		if (sauceConnectionRunning) {
			stopSauceConnect(function () { callback && callback(err); });
		} else {
			callback && callback(err);
		}
	});
}
870110
public static function Start ($output_callback = self::HANDLER_DEFAULT, $chunk_size = 0, $erase = null) {
		return ($erase !== self::HANDLER_DEFAULT) ? ob_start($output_callback, $chunk_size, $erase) : ob_start($output_callback, $chunk_size);
	}
120982
public function beginSession($callback, array $scope = [])
    {
        $requestUrl = $this->config['request_url'];

        if (0 < count($scope)) {
            $requestUrl .= ((false === strpos($requestUrl, '?')) ? '?' : '&') . 'scope=' . rawurlencode(implode(' ', $scope));
        }

        $response = $this->sendCustomOauthPostRequest(
            $requestUrl,
            [
                'callback' => $callback,
                'token' => null,
                'token_secret' => null,
            ]
        );

        parse_str($response->getBody(), $responseData);

        if (!isset($responseData['oauth_callback_confirmed'])) {
            throw new UnexpectedValueException('Oauth exchange is missing `oauth_callback_confirmed`.');
        } elseif (!isset($responseData['oauth_token'])) {
            throw new UnexpectedValueException('Oauth exchange is missing `oauth_token`.');
        } elseif (!isset($responseData['oauth_token_secret'])) {
            throw new UnexpectedValueException('Oauth exchange is missing `oauth_token_secret`.');
        }

        if ('true' !== $responseData['oauth_callback_confirmed']) {
            throw new UnexpectedValueException('Oauth exchange must have `oauth_callback_confirmed` as `true`.');
        }

        $this->authentication->getTokenStorage()->setRequestToken($responseData['oauth_token']);
        $this->authentication->getTokenStorage()->setRequestTokenSecret($responseData['oauth_token_secret']);

        $redirect = $this->config['authorize_url'];
        $redirect .= ((false === strpos($redirect, '?')) ? '?' : '&') . 'oauth_token=' . rawurlencode($this->authentication->getTokenStorage()->getRequestToken());

        return $redirect;
    }
669798
public function runCallback( \Closure $callback, $postReinitialize = true )
    {
        $this->requestInit();

        try
        {
            $return = $callback();
        }
        catch ( Exception $e )
        {
            $this->shutdown( $postReinitialize );
            throw $e;
        }

        $this->shutdown( $postReinitialize );

        return $return;
    }
1184439
private function runInterceptors(
        AnnotationCollection $annotations,
        InterceptionInterface $interception,
        Closure $callback
    ) {
        foreach ($annotations as $annotation) {
            foreach ($this->interceptors as $interceptor) {
                if (!$interceptor->canInterceptAnnotation($annotation)) {
                    continue;
                }

                $result = $callback($interceptor, $annotation, $interception);
                $this->resultCollector->collect($result);

                if ($result instanceof ContentAwareResultInterface && $result->hasContent()) {
                    return $result->getContent();
                }
            }
        }

        return null;
    }
947101
function ( options ) {
			this.protocol = options.protocol || 'http';
			this.port = options.port;
			this.server = options.server;
			this.path = options.path;
			this.proxy = options.proxy;
			this.jar = request.jar(); // create new cookie jar for each instance

			this.debug = options.debug;

			// set up logging
			const winston = require( 'winston' ),
				// file logging
				path = require( 'path' ),
				fs = require( 'fs' ),
				logDir = path.dirname( process.argv[ 1 ] ) + '/log/',
				logFile = logDir + path.basename( process.argv[ 1 ], '.js' ) + '.log',
				// how many tasks (i.e. requests) to run in parallel
				concurrency = options.concurrency || 3;

			this.logger = new ( winston.Logger )();

			// console logging
			if ( this.debug ) {
				this.logger.add( winston.transports.Console, {
					level: 'debug'
				} );
			}

			this.logger.cli();

			if ( fs.existsSync( logDir ) ) {
				this.logger.add( winston.transports.File, {
					colorize: true,
					filename: logFile,
					json: false,
					level: this.debug ? 'debug' : 'info'
				} );
			}

			// requests queue
			// @see https://github.com/caolan/async#queue
			this.queue = async.queue( function ( task, callback ) {
			// process the task (and call the provided callback once it's completed)
				task( callback );
			}, concurrency );

			// HTTP client
			this.formatUrl = require( 'url' ).format;

			this.userAgent = options.userAgent || ( `nodemw/${VERSION} (node.js ${process.version}; ${process.platform} ${process.arch})` );
			this.version = VERSION;

			// debug info
			this.info( process.argv.join( ' ' ) );
			this.info( this.userAgent );

			let port = this.port ? `:${this.port}` : '';

			this.info( `Using <${this.protocol}://${this.server}${port}${this.path}/api.php> as API entry point` );
			this.info( '----' );
		}
427934
public function AssignCallback($Callback, $Options = NULL) {
      if (!is_callable($Callback)) return FALSE;
      
      $this->Callback = $Callback;
      $this->CallbackOptions = $Options;
   }
717564
public function on($key,$func,$priority=10,$options=array()) {
		$call = $options ? array($func,$options) : $func;
		if ($e = &$this->f3->ref($this->ekey.$key))
			$e[$priority][] = $call;
		else
			$e = array($priority=>array($call));
		krsort($e);
	}
258078
public function execute(\Closure $callback = null)
    {
        $stacks = $this->buildStacks();

        foreach ($stacks as $requests) {
            foreach ($requests as $request) {
                $status = curl_multi_add_handle($this->handle, $request->getHandle());
                if ($status !== CURLM_OK) {
                    throw new \Exception(sprintf(
                        'Unable to add request to cURL multi handle (code #%u)',
                        $status
                    ));
                }
            }

            $this->dispatch();

            foreach ($requests as $request) {
                $request->setRawResponse(curl_multi_getcontent($request->getHandle()));
                curl_multi_remove_handle($this->handle, $request->getHandle());

                if ($callback !== null) {
                    $callback($request->getResponse());
                }
            }
        }
    }
1325222
private function intercept(array &$interceptors, &$request, &$method, &$metadata, &$options, callable $callback)
    {
        /** @var Client\Interceptors\Base $i */
        $i = array_shift($interceptors);
        if ($i) {
            $i->setRequest($request);
            $i->setMethod($method);
            $i->setMetadata($metadata);
            $client = $this->getClient();
            $i->setStub($client);
            return $i->call(function () use (
                &$i,
                &$interceptors,
                &$method,
                &$request,
                &$metadata,
                &$options,
                &$callback
            ) {
                $metadata = $i->getMetadata();
                $request = $i->getRequest();
                if (count($interceptors) > 0) {
                    return $this->intercept($interceptors, $request, $method, $metadata, $options, $callback);
                } else {
                    return $callback();
                }
            });
        } else {
            return $callback();
        }
    }