Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/nherit log level from flowr #46

Open
wants to merge 7 commits into
base: base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/application-manager/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const monitorActivity = (browserWindow: BrowserWindow, timeout: number, c
log.info(`Activity monitor enabled (timeout value: ${timeout}ms)`)

const watchDogTimeout = 30000 // ping every 30 s
let watchDogTimer: number | undefined
let watchDogTimer: NodeJS.Timeout

const start = () => {
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/players/abstractPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ export {
IPlayer,
PlayProps,
SubtitlesProps,
}
}
1 change: 1 addition & 0 deletions src/frontend/src/players/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class Player extends AbstractPlayer {
if (!this.playPipelineHeadOutput && this.playPipelineTail) {
return
}

this.log.info('--------- SETTING SUBTITLE PID', subtitlesPid, '---------')
if (this.playPipelineTail === this.transmuxer) {
// Switch to FFMPEG
Expand Down
15 changes: 13 additions & 2 deletions src/frontend/src/players/vlc/player.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChildProcess, spawn } from 'child_process'
import { app, IpcMainEvent, WebContents } from 'electron'
import { IPlayerStore, PlayerPosition } from '../../interfaces/playerStore'
import { ILogger } from '../../logging/types'
import { ILogger, LogSeverity } from '../../logging/types'
import { Store } from '../../store'
import { AbstractPlayer, PlayProps } from '../abstractPlayer'
import { IMessage, LogMessage, MessageDataType, MessageType, ProcessMessaging, VLCLogLevel } from './messaging'
Expand All @@ -25,6 +25,7 @@ export class VlcPlayer extends AbstractPlayer {
private playerPosition: ResizeProps = { x: 0, y: 0, width: 0, height: 0 }
private keepAliveTimeout?: ResetableTimeout
private frontendWebView?: WebContents
private logLevel: LogSeverity = LogSeverity.INFO;

constructor(private readonly flowrWindow: FlowrWindow, store: Store<IPlayerStore>) {
super(store)
Expand All @@ -33,10 +34,13 @@ export class VlcPlayer extends AbstractPlayer {
this.onError = this.onError.bind(this)
this.onMessage = this.onMessage.bind(this)
this.resize = this.resize.bind(this)
this.setLogLevel = this.setLogLevel.bind(this)
/* eslint-enable @typescript-eslint/no-unsafe-assignment */

// eslint-disable-next-line @typescript-eslint/unbound-method
this.registerEvent('resize', this.resize)
// eslint-disable-next-line @typescript-eslint/unbound-method
this.registerEvent('setlogLevel',this.setLogLevel)
}

private resetKeepAlive() {
Expand All @@ -62,10 +66,11 @@ export class VlcPlayer extends AbstractPlayer {
}

const path = this.store.get('pipeline')?.metadata?.applicationPath

if (!path) {
throw Error('No path is defined for VLC executable. Please configure it in flowr-admin\'s settings')
}
const args = [url, toRectangle(this.playerPosition), this.store.get('position')]
const args = [url, toRectangle(this.playerPosition), this.store.get('position'),this.flowrWindow.store.get('logLevel')]
const process = spawn(path, args)

/* eslint-disable @typescript-eslint/unbound-method */
Expand Down Expand Up @@ -121,6 +126,7 @@ export class VlcPlayer extends AbstractPlayer {
case VLCLogLevel.ERROR:
return this.log.error.bind(this.log) as ILogger['error']
case VLCLogLevel.INFO:
return this.log.info.bind(this.log) as ILogger['info']
default:
return this.log.info.bind(this.log) as ILogger['info']
}
Expand Down Expand Up @@ -189,6 +195,11 @@ export class VlcPlayer extends AbstractPlayer {
// not required now, maybe later
}

setLogLevel(_: IpcMainEvent, logLevel: LogSeverity): void {
this.logLevel = logLevel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any place where this variable is used. What is its purpose ?

this.messaging.send(MessageType.LOG, {value: this.logLevel})
}

resize(_: IpcMainEvent, { x, y, width, height }: ResizeProps): void {
const windowPosition = this.flowrWindow.getBounds()
this.playerPosition = {
Expand Down
1 change: 0 additions & 1 deletion src/launcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ async function main() {
maxTab : 0,
})
})

ipcMain.on('flowrLanguageChanged', (e: Event, lang: string) => applicationManager.languageChanged(lang))
} catch (e) {
console.error('Error in init', e)
Expand Down