Skip to content

Commit

Permalink
fix: use different approach
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Sep 12, 2024
1 parent 7f35c53 commit 61fdc95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 3 additions & 9 deletions api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { readFile, realpath } from 'fs/promises'
import { generate } from 'selfsigned'
import ZnifferManager, { ZnifferConfig } from './lib/ZnifferManager'
import { getAllNamedScaleGroups, getAllSensors } from '@zwave-js/core'
import { Writable } from 'stream'

const createCertificate = promisify(generate)

Expand Down Expand Up @@ -441,14 +440,9 @@ async function destroyPlugins() {

function setupInterceptor() {
// intercept logs and redirect them to socket
loggers.logStream.pipe(
new Writable({
write(chunk, encoding, callback) {
socketManager.io.emit(socketEvents.debug, chunk.toString())
callback()
},
}),
)
loggers.logStream.on('data', (chunk) => {
socketManager.io.emit(socketEvents.debug, chunk.toString())
})
}

async function parseDir(dir: string): Promise<StoreFileEntry[]> {
Expand Down
3 changes: 1 addition & 2 deletions api/lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ import { ConfigManager, DeviceConfig } from '@zwave-js/config'
import { readFile } from 'fs/promises'
import backupManager, { NVM_BACKUP_PREFIX } from './BackupManager'
import { socketEvents } from './SocketEvents'
import { PassThrough } from 'stream'

export const deviceConfigPriorityDir = storeDir + '/config'

Expand Down Expand Up @@ -2268,7 +2267,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
zwaveOptions.logConfig.transports = [logTransport]

logTransport.stream.on('data', (data) => {
LogManager.logStream.push(Buffer.from(data.message))
this.socket.emit(socketEvents.debug, data.message.toString())
})

try {
Expand Down

0 comments on commit 61fdc95

Please sign in to comment.