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:
node-version: 18.x
- run: npm install
- run: npm test
- run: npm test -- --silent=false
env:
CI: true

View File

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

View File

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