From b7ae407657990f1d31fa4141906cc797fde0f634 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Mon, 25 Sep 2017 15:03:13 -0700 Subject: [PATCH] Log function rewrites when serving Hosting locally. --- lib/hosting/functionsProxy.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/hosting/functionsProxy.js b/lib/hosting/functionsProxy.js index 1f1d4788b50..06d1851eb30 100644 --- a/lib/hosting/functionsProxy.js +++ b/lib/hosting/functionsProxy.js @@ -1,6 +1,7 @@ 'use strict'; var _ = require('lodash'); +var logger = require('../logger'); var request = require('request'); var RSVP = require('rsvp'); @@ -27,12 +28,16 @@ function _makeVary(vary) { module.exports = function(options) { return function(rewrite) { var url; + var destLabel; if (_.includes(options.targets, 'functions')) { + destLabel = 'local'; url = 'http://localhost:' + (options.port + 1) + '/' + getProjectId(options) + '/us-central1/' + rewrite.function; } else { + destLabel = 'live'; url = 'https://us-central1-' + getProjectId(options) + '.cloudfunctions.net/' + rewrite.function; } return RSVP.resolve(function(req, res, next) { + logger.info('[hosting] Rewriting', req.url, 'to', destLabel, 'function', rewrite.function); // Extract the __session cookie from headers to forward it to the functions var sessionCookie = (req.headers.cookie || '') .split(/; ?/)