Skip to content

Commit d9afcc1

Browse files
committed
Logging also the server
1 parent 26988f4 commit d9afcc1

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/clients/utils.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,36 @@ export function round(number, fraction=2) {
4848

4949
export const log = console.log
5050

51-
export function logConnecting(client, url) {
52-
log(`${chalk.green(client)} client connecting to ${chalk.yellow(url)}`)
51+
const port2serverMap = {
52+
5000: 'FastAPI',
53+
5001: 'Flask',
54+
5002: 'Pyramid',
55+
5003: 'Tornado',
56+
5004: 'Flask-Socket.IO',
57+
5005: 'Python-Socket.IO',
58+
5006: 'Eventlet',
59+
5007: 'FastAPI WebSocket',
60+
5008: 'Tornado WebSocket',
61+
5009: 'WebSockets'
62+
}
63+
64+
export function logConnecting(client, url, serverByPort=true) {
65+
let message = ''
66+
const clientConnectingTo = `${chalk.green(client)} client connecting to`
67+
if (serverByPort) {
68+
const port = url.match(/:(\d+)/)[1]
69+
const server = port2serverMap[port]
70+
const serverOn = `${chalk.cyan(server)} on`
71+
message = `${clientConnectingTo} ${serverOn} ${chalk.yellow(url)}`
72+
} else {
73+
message = `${clientConnectingTo} ${chalk.yellow(url)}`
74+
}
75+
76+
log(message)
5377
}
5478

5579
export function logIterations(iters) {
56-
log(`Running test with ${chalk.cyan(iters.toLocaleString())} iterations`)
80+
log(`Running test with ${chalk.red(iters.toLocaleString())} iterations`)
5781
}
5882

5983
export function logError(err) {

0 commit comments

Comments
 (0)