Called by {#connection} to build a connection.

 Request logger if logger is not nil
340318
def build_connection
      RestClient.log = config.logger if config.logger
      RestClient::Resource.new(config.base_url, config.options.merge(auth_options))
    end
1214662
function Connection (options) {
  options = utils.clone(options || {});

  var ns = this._ns = utils.createNamespace(options);
  var id = this.id = options.id || utils.uniqueId('connection');
  this._debug = utils.debug('connection:' + id);
  var me = this;

  // create controller connection
  this._host = options.host || define.host;
  this._port = options.port || define.port;
  process.nextTick(function () {
    me._debug('trying reconnect');
    me._reconnect();
  });

  me._queue = [];
  ['send', 'registerKey', 'deleteKey', 'deleteKeys', 'keys'].forEach(function (method) {
    me[method] = me._wrapMethod(me[method], method);
  });
  me.on('ready', function () {
    me._debug('emit listen');
    me.emit('listen');
    me._processQueue();
  });
}
832956
def dispatch(req)
      debug_log(req)

      response = Response.new
      @request = req

      if ! @request.valid?
        response.body = handle_invalid_request
        response.code = :error
      else
        begin
          debug_log("do lookup for #{@request.selector}")
          @params, block = lookup(@request.selector)

          #
          # call the block that handles this lookup
          #
          response.body = block.bind(self).call
          response.code = :success
        rescue Gopher::NotFoundError => e
          debug_log("#{@request.selector} -- not found")
          response.body = handle_not_found
          response.code = :missing
        rescue Exception => e
          debug_log("#{@request.selector} -- error")
          debug_log(e.inspect)
          debug_log(e.backtrace)

          response.body = handle_error(e)
          response.code = :error
        end
      end

      access_log(req, response)
      response
    end
218423
function Connection(conn) {
	if(!(this instanceof Connection)) {
		return new Connection(conn);
	}
	var self = this;
	if(!conn) { throw new TypeError("no connection set"); }
	self._connection = conn;
}
767395
def get(path, params = nil, headers = {}, auth = true)
      request(path: path, query: params, headers: headers, auth: auth)
    end
120094
function onConnectionError(err) {
        var codeName = errors.classify(err);

        var loggerInfo = conn.extendLogInfo({
            error: err
        });

        if (codeName === 'Timeout' ||
            codeName === 'NetworkError') {
            self.logger.warn('Got a connection error', loggerInfo);
        } else {
            self.logger.error('Got an unexpected connection error', loggerInfo);
        }
        delete self.serverConnections[socketRemoteAddr];
    }
1277105
def log(level, message = nil)
      level, message = :info, level if message.nil?
      Resqued::Logging.logger.send(level, self.class.name) { message }
    end
685986
def setup_logger
      @logger = flexmock("logger")
      @logger.should_receive(:level).and_return(:info).by_default
      @logger.should_receive(:error).by_default.and_return { |m| raise m }
      @logger.should_receive(:warn).by_default.and_return { |m| raise m }
      @logger.should_receive(:info).by_default
      @logger.should_receive(:debug).by_default
      # Note that the following puts the mock logger inside the default Decorator
      # so the only way to mock the :exception interface is to flexmock the
      # logger if the constructed class that uses RightSupport::Log::Mixin
      RightSupport::Log::Mixin.default_logger = @logger
    end
430898
function (connection, sessionRead) {
        connection = OT.Connection.fromHash(connection);
        if (sessionRead || session.connection && connection.id !== session.connection.id) {
          session.connections.add( connection );
          delayedSessionEvents.triggerConnectionCreated(connection);
        }

        OT.$.forEach(OT.$.keys(unconnectedStreams), function(streamId) {
          var stream = unconnectedStreams[streamId];
          if (stream && connection.id === stream.connection.id) {
            // dispatch streamCreated event now that the connectionCreated has been dispatched
            parseAndAddStreamToSession(stream, session);
            delete unconnectedStreams[stream.id];
            
            var payload = {
              debug: sessionRead ? 'connection came in session#read' :
                'connection came in connection#created',
              streamId : stream.id,
              connectionId : connection.id
            };
            session.logEvent('streamCreated', 'warning', payload);
          }
        });
        
        return connection;
      }
270265
function() {
      io = io.listen(app);
      io.set("log level", 1);
      io.sockets.on("connection", function(socket) {
        connections += 1;
        console.log("   info  -".cyan, ("new connection. Connections: " + connections).yellow);

        socket.on("disconnect", function() {
          connections -= 1;
          console.log("   info  -".cyan, ("connection closed. Connections: " + connections).yellow);
        });

        socket.on("iframe-loaded", function(data) {
          urlData[data.id].counter--;
          console.log("   info  -".cyan, ("client sends event iframe-loaded").yellow, JSON.stringify(data));
        });
      });
    }
1034367
function (queryKey, params, fn) {
    this.connection.query(templates[queryKey], params, function (err, result) {
      if (err) {
        fn(err, null);
      } else {
        fn(null, result.length ? result[0] : null);
      }
    });
  }
855361
function _checkConnection(conn) {
  // Return Promise for getConnection callback wrapping
  return new Promise((resolve, reject) => {
    if (conn) {
      resolve(conn);
    } else {
      _pool.getConnection((err, conn) => {
        if (err) reject(err); // Reject this error
        else resolve(conn); // Resolve the connection
      })
    }
  });
}
48553
def request(uri, data=nil, verb=:post)
      @logger.info(uri) if @logger
      auth_check
      query = {
        path: File.join('v1.0/me/', URI.escape(uri)),
        headers: {
          'Authorization': "Bearer #{@access_token.token}"
        }
      }
      if data
        query[:body] = JSON.generate(data)
        query[:headers]['Content-Type'] = 'application/json'
        @logger.info(query[:body]) if @logger
        verb = :post unless [:post, :put, :patch, :delete].include?(verb)
        response = @conn.send(verb, query)
      else
        response = @conn.get(query)
      end
      JSON.parse(response.body)
    end
1187870
def call!(request)
      operation = proc {
        app.dispatch(request)
      }
      callback = proc {|result|
        send_response result
        close_connection_after_writing
      }

      #
      # if we don't want to block on slow calls, use EM#defer
      # @see http://eventmachine.rubyforge.org/EventMachine.html#M000486
      #
      if app.non_blocking?
        EventMachine.defer( operation, callback )
      else
        callback.call(operation.call)
      end
    end
22110
function(logger, LevelController, moduleDir) {
    if(logger === null) {
        this.logger = new ConsoleLogger(false);
    } else if(logger instanceof BaseLogger) {
        this.logger = logger;
    } else {
        throw Errors.invalidParameter('logger', 'BaseLogger');
    }
    
    this.commandLineParser = null;
    this.moduleDir = moduleDir;
    this.LevelController = LevelController;
}
156714
def log(type, str)
      case type
      when :connect
        @logger << Colors.green(str)
      when :close
        @logger << Colors.red(str)
      when :read
        @logger << Colors.gold(str)
      when :write
        @logger << Colors.white(str)
      else
        raise "unknown event type: #{type.inspect}"
      end
    end
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }