Verified Commit 37380994 authored by Aral Balkan's avatar Aral Balkan
Browse files

Improve proxy server setup log message clarity

parent d64a80a2
...@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ...@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Development] - in progress…
### Improved
- HTTP and WebSocket proxy messages are now easier to understand (#38).
## [16.0.0] - 2020-11-05 ## [16.0.0] - 2020-11-05
### Breaking change ### Breaking change
......
...@@ -651,7 +651,18 @@ class Site { ...@@ -651,7 +651,18 @@ class Site {
const proxyWebSocketUrl = `ws://localhost:${this.proxyPort}` const proxyWebSocketUrl = `ws://localhost:${this.proxyPort}`
let prettyLog = function (message) { let prettyLog = function (message) {
this.log(` 🔁 ❨site.js❩ ${message}`)
const match = /^\[HPM\] Proxy created: \/ -> (ws|http):\/\/localhost:(\d+)$/.exec(message)
if (match === null) {
// Unexpected message, log as warning.
this.log(` 🔁 ${clr('❨site.js❩ Unexpected message from proxy middleware:', 'yellow')} ${message}`)
} else {
// Expected message. Log after improving it for clarity.
const { proxyType, proxyProtocol } = match[1] === 'ws' ? { proxyType: 'WebSocket', proxyProtocol: 'wss' } : { proxyType: 'HTTP', proxyProtocol: 'https' }
const proxyPort = match[2]
this.log(` 🔁 ❨site.js❩ ${clr(`${proxyType} proxy`, 'green')} set up for port ${clr(proxyPort, 'cyan')} at ${clr(`${proxyProtocol}://localhost`, 'cyan')}.`)
}
} }
prettyLog = prettyLog.bind(this) prettyLog = prettyLog.bind(this)
...@@ -1100,7 +1111,6 @@ class Site { ...@@ -1100,7 +1111,6 @@ class Site {
// Callback used in proxy servers. // Callback used in proxy servers.
proxyCallback (server) { proxyCallback (server) {
const location = this.prettyLocation() const location = this.prettyLocation()
this.log(` 🚚 ❨site.js❩ Proxying: HTTP/WS on localhost:${this.proxyPort} ←→ HTTPS/WSS on ${location}`)
this.showStatisticsUrl(location) this.showStatisticsUrl(location)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment