mirror of
https://github.com/streamwall/streamwall.git
synced 2025-12-06 01:45:37 -05:00
Add debug logging, remove file-based logging for now
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,5 +5,4 @@ node_modules
|
|||||||
reports
|
reports
|
||||||
|
|
||||||
# Individual files
|
# Individual files
|
||||||
junit.xml
|
junit.xml
|
||||||
streamwall.log
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"prune": "rm -rf dist",
|
"prune": "rm -rf dist",
|
||||||
"start": "npm run build -- --stats=errors-only && electron dist",
|
"start": "npm run build -- --stats=errors-only && electron dist",
|
||||||
"start-local": "npm run build -- --stats=errors-only && electron dist --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev",
|
"start-local": "npm run build -- --stats=errors-only && electron dist --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev",
|
||||||
"start-dev": "NODE_DEBUG=* npm run build -- --stats=verbose && NODE_DEBUG=* electron dist --enable-logging --control.address=http://localhost:4444 --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev",
|
"start-dev": "npm run build -- --stats=verbose && electron dist --enable-logging --control.address=http://localhost:4444 --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev",
|
||||||
"test-full": "jest",
|
"test-full": "jest",
|
||||||
"test": "jest --ci --reporters=default --reporters=jest-junit --testPathIgnorePatterns=src/node/server.test.js --coverage"
|
"test": "jest --ci --reporters=default --reporters=jest-junit --testPathIgnorePatterns=src/node/server.test.js --coverage"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import util from 'util'
|
||||||
import yargs from 'yargs'
|
import yargs from 'yargs'
|
||||||
import TOML from '@iarna/toml'
|
import TOML from '@iarna/toml'
|
||||||
import * as Y from 'yjs'
|
import * as Y from 'yjs'
|
||||||
@@ -211,16 +212,6 @@ function parseArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main(argv) {
|
async function main(argv) {
|
||||||
const fs = require('fs');
|
|
||||||
const util = require('util');
|
|
||||||
const log_file = fs.createWriteStream('streamwall.log', { flags: 'w' });
|
|
||||||
const log_stdout = process.stdout;
|
|
||||||
|
|
||||||
console.log = console.info = console.warn = console.error = function(d) {
|
|
||||||
log_file.write(util.format(d) + '\n');
|
|
||||||
log_stdout.write(util.format(d) + '\n');
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reject all permission requests from web content.
|
// Reject all permission requests from web content.
|
||||||
session
|
session
|
||||||
.fromPartition('persist:session')
|
.fromPartition('persist:session')
|
||||||
@@ -228,8 +219,10 @@ async function main(argv) {
|
|||||||
callback(false)
|
callback(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.debug('Loading persistence data...')
|
||||||
const persistData = await persistence.load()
|
const persistData = await persistence.load()
|
||||||
|
|
||||||
|
console.debug('Creating StreamWindow...')
|
||||||
const idGen = new StreamIDGenerator()
|
const idGen = new StreamIDGenerator()
|
||||||
const localStreamData = new LocalStreamData()
|
const localStreamData = new LocalStreamData()
|
||||||
const overlayStreamData = new LocalStreamData()
|
const overlayStreamData = new LocalStreamData()
|
||||||
@@ -245,6 +238,7 @@ async function main(argv) {
|
|||||||
})
|
})
|
||||||
streamWindow.init()
|
streamWindow.init()
|
||||||
|
|
||||||
|
console.debug('Creating Auth...')
|
||||||
const auth = new Auth({
|
const auth = new Auth({
|
||||||
adminUsername: argv.control.username,
|
adminUsername: argv.control.username,
|
||||||
adminPassword: argv.control.password,
|
adminPassword: argv.control.password,
|
||||||
@@ -256,6 +250,7 @@ async function main(argv) {
|
|||||||
let twitchBot = null
|
let twitchBot = null
|
||||||
let streamdelayClient = null
|
let streamdelayClient = null
|
||||||
|
|
||||||
|
console.debug('Creating initial state...')
|
||||||
let clientState = new StateWrapper({
|
let clientState = new StateWrapper({
|
||||||
config: {
|
config: {
|
||||||
width: argv.window.width,
|
width: argv.window.width,
|
||||||
@@ -300,21 +295,29 @@ async function main(argv) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const onMessage = async (msg, respond) => {
|
const onMessage = async (msg, respond) => {
|
||||||
|
console.debug('Received message:', msg)
|
||||||
if (msg.type === 'set-listening-view') {
|
if (msg.type === 'set-listening-view') {
|
||||||
|
console.debug('Setting listening view:', msg.viewIdx)
|
||||||
streamWindow.setListeningView(msg.viewIdx)
|
streamWindow.setListeningView(msg.viewIdx)
|
||||||
} else if (msg.type === 'set-view-background-listening') {
|
} else if (msg.type === 'set-view-background-listening') {
|
||||||
|
console.debug('Setting view background listening:', msg.viewIdx, msg.listening)
|
||||||
streamWindow.setViewBackgroundListening(msg.viewIdx, msg.listening)
|
streamWindow.setViewBackgroundListening(msg.viewIdx, msg.listening)
|
||||||
} else if (msg.type === 'set-view-blurred') {
|
} else if (msg.type === 'set-view-blurred') {
|
||||||
|
console.debug('Setting view blurred:', msg.viewIdx, msg.blurred)
|
||||||
streamWindow.setViewBlurred(msg.viewIdx, msg.blurred)
|
streamWindow.setViewBlurred(msg.viewIdx, msg.blurred)
|
||||||
} else if (msg.type === 'rotate-stream') {
|
} else if (msg.type === 'rotate-stream') {
|
||||||
|
console.debug('Rotating stream:', msg.url, msg.rotation)
|
||||||
overlayStreamData.update(msg.url, {
|
overlayStreamData.update(msg.url, {
|
||||||
rotation: msg.rotation,
|
rotation: msg.rotation,
|
||||||
})
|
})
|
||||||
} else if (msg.type === 'update-custom-stream') {
|
} else if (msg.type === 'update-custom-stream') {
|
||||||
|
console.debug('Updating custom stream:', msg.url)
|
||||||
localStreamData.update(msg.url, msg.data)
|
localStreamData.update(msg.url, msg.data)
|
||||||
} else if (msg.type === 'delete-custom-stream') {
|
} else if (msg.type === 'delete-custom-stream') {
|
||||||
|
console.debug('Deleting custom stream:', msg.url)
|
||||||
localStreamData.delete(msg.url)
|
localStreamData.delete(msg.url)
|
||||||
} else if (msg.type === 'reload-view') {
|
} else if (msg.type === 'reload-view') {
|
||||||
|
console.debug('Reloading view:', msg.viewIdx)
|
||||||
streamWindow.reloadView(msg.viewIdx)
|
streamWindow.reloadView(msg.viewIdx)
|
||||||
} else if (msg.type === 'browse' || msg.type === 'dev-tools') {
|
} else if (msg.type === 'browse' || msg.type === 'dev-tools') {
|
||||||
if (
|
if (
|
||||||
@@ -346,13 +349,17 @@ async function main(argv) {
|
|||||||
console.error('Error:', error)
|
console.error('Error:', error)
|
||||||
}
|
}
|
||||||
} else if (msg.type === 'dev-tools') {
|
} else if (msg.type === 'dev-tools') {
|
||||||
|
console.debug('Opening DevTools for view:', msg.viewIdx)
|
||||||
streamWindow.openDevTools(msg.viewIdx, browseWindow.webContents)
|
streamWindow.openDevTools(msg.viewIdx, browseWindow.webContents)
|
||||||
}
|
}
|
||||||
} else if (msg.type === 'set-stream-censored' && streamdelayClient) {
|
} else if (msg.type === 'set-stream-censored' && streamdelayClient) {
|
||||||
|
console.debug('Setting stream censored:', msg.isCensored)
|
||||||
streamdelayClient.setCensored(msg.isCensored)
|
streamdelayClient.setCensored(msg.isCensored)
|
||||||
} else if (msg.type === 'set-stream-running' && streamdelayClient) {
|
} else if (msg.type === 'set-stream-running' && streamdelayClient) {
|
||||||
|
console.debug('Setting stream running:', msg.isStreamRunning)
|
||||||
streamdelayClient.setStreamRunning(msg.isStreamRunning)
|
streamdelayClient.setStreamRunning(msg.isStreamRunning)
|
||||||
} else if (msg.type === 'create-invite') {
|
} else if (msg.type === 'create-invite') {
|
||||||
|
console.debug('Creating invite for role:', msg.role)
|
||||||
const { secret } = await auth.createToken({
|
const { secret } = await auth.createToken({
|
||||||
kind: 'invite',
|
kind: 'invite',
|
||||||
role: msg.role,
|
role: msg.role,
|
||||||
@@ -360,6 +367,7 @@ async function main(argv) {
|
|||||||
})
|
})
|
||||||
respond({ name: msg.name, secret })
|
respond({ name: msg.name, secret })
|
||||||
} else if (msg.type === 'delete-token') {
|
} else if (msg.type === 'delete-token') {
|
||||||
|
console.debug('Deleting token:', msg.tokenId)
|
||||||
auth.deleteToken(msg.tokenId)
|
auth.deleteToken(msg.tokenId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,7 +381,9 @@ async function main(argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argv.control.address) {
|
if (argv.control.address) {
|
||||||
|
console.debug('Initializing web server...')
|
||||||
const webDistPath = path.join(app.getAppPath(), 'web')
|
const webDistPath = path.join(app.getAppPath(), 'web')
|
||||||
|
console.debug('1')
|
||||||
await initWebServer({
|
await initWebServer({
|
||||||
certDir: argv.cert.dir,
|
certDir: argv.cert.dir,
|
||||||
certProduction: argv.cert.production,
|
certProduction: argv.cert.production,
|
||||||
@@ -388,12 +398,17 @@ async function main(argv) {
|
|||||||
onMessage,
|
onMessage,
|
||||||
stateDoc,
|
stateDoc,
|
||||||
})
|
})
|
||||||
|
console.debug('2')
|
||||||
if (argv.control.open) {
|
if (argv.control.open) {
|
||||||
|
console.debug('3')
|
||||||
shell.openExternal(argv.control.address)
|
shell.openExternal(argv.control.address)
|
||||||
|
console.debug('4')
|
||||||
}
|
}
|
||||||
|
console.debug('5')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv.streamdelay.key) {
|
if (argv.streamdelay.key) {
|
||||||
|
console.debug('Setting up Streamdelay client...')
|
||||||
streamdelayClient = new StreamdelayClient({
|
streamdelayClient = new StreamdelayClient({
|
||||||
endpoint: argv.streamdelay.endpoint,
|
endpoint: argv.streamdelay.endpoint,
|
||||||
key: argv.streamdelay.key,
|
key: argv.streamdelay.key,
|
||||||
@@ -405,6 +420,7 @@ async function main(argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argv.twitch.token) {
|
if (argv.twitch.token) {
|
||||||
|
console.debug('Setting up Twitch bot...')
|
||||||
twitchBot = new TwitchBot(argv.twitch)
|
twitchBot = new TwitchBot(argv.twitch)
|
||||||
twitchBot.on('setListeningView', (idx) => {
|
twitchBot.on('setListeningView', (idx) => {
|
||||||
streamWindow.setListeningView(idx)
|
streamWindow.setListeningView(idx)
|
||||||
@@ -426,34 +442,42 @@ async function main(argv) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataSources = [
|
const dataSources = [
|
||||||
...argv.data['json-url'].map((url) =>
|
...argv.data['json-url'].map((url) => {
|
||||||
markDataSource(pollDataURL(url, argv.data.interval), 'json-url'),
|
console.debug('Setting data source from json-url:', url)
|
||||||
),
|
return markDataSource(pollDataURL(url, argv.data.interval), 'json-url')
|
||||||
...argv.data['toml-file'].map((path) =>
|
}),
|
||||||
markDataSource(watchDataFile(path), 'toml-file'),
|
...argv.data['toml-file'].map((path) => {
|
||||||
),
|
console.debug('Setting data source from toml-file:', path)
|
||||||
|
return markDataSource(watchDataFile(path), 'toml-file')
|
||||||
|
}),
|
||||||
markDataSource(localStreamData.gen(), 'custom'),
|
markDataSource(localStreamData.gen(), 'custom'),
|
||||||
overlayStreamData.gen(),
|
overlayStreamData.gen(),
|
||||||
]
|
]
|
||||||
|
|
||||||
for await (const rawStreams of combineDataSources(dataSources)) {
|
for await (const rawStreams of combineDataSources(dataSources)) {
|
||||||
|
console.debug('Processing streams:', rawStreams)
|
||||||
const streams = idGen.process(rawStreams)
|
const streams = idGen.process(rawStreams)
|
||||||
updateState({ streams })
|
updateState({ streams })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
console.debug('Parsing command line arguments...')
|
||||||
const argv = parseArgs()
|
const argv = parseArgs()
|
||||||
if (argv.help) {
|
if (argv.help) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.debug('Initializing Sentry...')
|
||||||
if (argv.telemetry.sentry) {
|
if (argv.telemetry.sentry) {
|
||||||
Sentry.init({ dsn: SENTRY_DSN })
|
Sentry.init({ dsn: SENTRY_DSN })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.debug('Setting up Electron...')
|
||||||
app.commandLine.appendSwitch('high-dpi-support', 1)
|
app.commandLine.appendSwitch('high-dpi-support', 1)
|
||||||
app.commandLine.appendSwitch('force-device-scale-factor', 1)
|
app.commandLine.appendSwitch('force-device-scale-factor', 1)
|
||||||
|
|
||||||
|
console.debug('Enabling Electron sandbox...')
|
||||||
app.enableSandbox()
|
app.enableSandbox()
|
||||||
app
|
app
|
||||||
.whenReady()
|
.whenReady()
|
||||||
@@ -465,5 +489,6 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
console.debug('Starting Streamwall...')
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ export default async function initWebServer({
|
|||||||
onMessage,
|
onMessage,
|
||||||
stateDoc,
|
stateDoc,
|
||||||
}) {
|
}) {
|
||||||
|
console.debug('Parsing URL:', baseURL)
|
||||||
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
|
||||||
@@ -252,6 +253,7 @@ export default async function initWebServer({
|
|||||||
port = overridePort
|
port = overridePort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.debug('Initializing web server:', { hostname, port })
|
||||||
const { app } = initApp({
|
const { app } = initApp({
|
||||||
auth,
|
auth,
|
||||||
baseURL,
|
baseURL,
|
||||||
|
|||||||
Reference in New Issue
Block a user