Log messages for streaming debug

This commit is contained in:
simojenki
2021-06-19 13:15:35 +10:00
parent e6378de25d
commit cb987aeacb
2 changed files with 5 additions and 2 deletions

View File

@@ -142,6 +142,7 @@ function server(
app.head("/stream/track/:id", async (req, res) => { app.head("/stream/track/:id", async (req, res) => {
const id = req.params["id"]!; const id = req.params["id"]!;
const accessToken = req.headers[BONOB_ACCESS_TOKEN_HEADER] as string; const accessToken = req.headers[BONOB_ACCESS_TOKEN_HEADER] as string;
logger.info(`Stream HEAD requested for ${id}, accessToken=${accessToken}`)
const authToken = accessTokens.authTokenFor(accessToken); const authToken = accessTokens.authTokenFor(accessToken);
if (!authToken) { if (!authToken) {
return res.status(401).send(); return res.status(401).send();
@@ -165,6 +166,7 @@ function server(
app.get("/stream/track/:id", async (req, res) => { app.get("/stream/track/:id", async (req, res) => {
const id = req.params["id"]!; const id = req.params["id"]!;
const accessToken = req.headers[BONOB_ACCESS_TOKEN_HEADER] as string; const accessToken = req.headers[BONOB_ACCESS_TOKEN_HEADER] as string;
logger.info(`Stream requested for ${id}, accessToken=${accessToken}`)
const authToken = accessTokens.authTokenFor(accessToken); const authToken = accessTokens.authTokenFor(accessToken);
if (!authToken) { if (!authToken) {
return res.status(401).send(); return res.status(401).send();
@@ -182,6 +184,7 @@ function server(
it.stream({ trackId: id, range: req.headers["range"] || undefined }) it.stream({ trackId: id, range: req.headers["range"] || undefined })
) )
.then((trackStream) => { .then((trackStream) => {
logger.info(`Streaming ${id}, status=${trackStream.status}, headers=(${JSON.stringify(trackStream.headers)})`)
res.status(trackStream.status); res.status(trackStream.status);
Object.entries(trackStream.headers) Object.entries(trackStream.headers)
.filter(([_, v]) => v !== undefined) .filter(([_, v]) => v !== undefined)

View File

@@ -1,6 +1,6 @@
global.console = { global.console = {
// log: console.log, log: console.log,
log: jest.fn(), // console.log are ignored in tests //log: jest.fn(), // console.log are ignored in tests
// Keep native behaviour for other methods, use those to print out things in your own tests, not `console.log` // Keep native behaviour for other methods, use those to print out things in your own tests, not `console.log`
error: console.error, error: console.error,