Debug logging

This commit is contained in:
sayhiben
2024-05-05 20:04:05 -07:00
parent 6977045f26
commit 8d937161e0
3 changed files with 11 additions and 2 deletions

View File

@@ -12,6 +12,6 @@ jobs:
with: with:
node-version: 18.x node-version: 18.x
- run: npm install - run: npm install
- run: npm test - run: npm test -- --silent=false
env: env:
CI: true CI: true

View File

@@ -247,8 +247,10 @@ export default async function initWebServer({
let { protocol, hostname, port } = new URL(baseURL) let { protocol, hostname, port } = new URL(baseURL)
if (!port) { if (!port) {
port = protocol === 'https:' ? 443 : 80 port = protocol === 'https:' ? 443 : 80
console.debug(`No port specified in URL, defaulting to ${port}`)
} }
if (overridePort) { if (overridePort) {
console.debug(`Overriding port ${port} with ${overridePort}`)
port = overridePort port = overridePort
} }
@@ -263,7 +265,9 @@ export default async function initWebServer({
}) })
let server let server
console.debug(`Starting server on ${protocol}//${hostname}:${port}`)
if (protocol === 'https:' && certDir) { if (protocol === 'https:' && certDir) {
console.debug('Using HTTPS with certificate from', certDir)
const { key, cert } = await simpleCert({ const { key, cert } = await simpleCert({
dataDir: certDir, dataDir: certDir,
commonName: hostname, commonName: hostname,
@@ -278,6 +282,7 @@ export default async function initWebServer({
const listen = promisify(server.listen).bind(server) const listen = promisify(server.listen).bind(server)
await listen(port, overrideHostname || hostname) await listen(port, overrideHostname || hostname)
console.debug(`Server started on ${protocol}//${hostname}:${port}`)
return { server } return { server }
} }

View File

@@ -63,12 +63,14 @@ describe('streamwall server', () => {
stateDoc, stateDoc,
})) }))
request = supertest(server) request = supertest(server)
console.debug(`Server listening on ${baseURL}`)
auth.on('state', (authState) => { auth.on('state', (authState) => {
clientState.update({ auth: authState }) clientState.update({ auth: authState })
}) })
}) })
afterEach(() => { afterEach(() => {
console.debug('Closing server')
server.close() server.close()
for (const ws of sockets) { for (const ws of sockets) {
ws.close() ws.close()
@@ -76,11 +78,12 @@ describe('streamwall server', () => {
}) })
function socket(options) { function socket(options) {
console.debug(`Creating websocket at ${hostname}:${port}`)
const ws = new WebSocket(`ws://${hostname}:${port}/ws`, [], { const ws = new WebSocket(`ws://${hostname}:${port}/ws`, [], {
...options, ...options,
origin: baseURL, origin: baseURL,
}) })
sockets.push(ws) console.debug(`Websocket created at ${hostname}:${port}`)
const msgs = on(ws, 'message') const msgs = on(ws, 'message')
@@ -102,6 +105,7 @@ describe('streamwall server', () => {
} }
function socketFromSecret(secret) { function socketFromSecret(secret) {
console.debug("Socket from secret")
return socket({ return socket({
headers: { Cookie: `${SESSION_COOKIE_NAME}=${secret}` }, headers: { Cookie: `${SESSION_COOKIE_NAME}=${secret}` },
}) })