mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Fix dmpWorker logging
dmpWorker is run as a childProcess, which is a completely separate nodejs instance. As such, the `logger` it obtains is a separate instance than the one in the parent. The parent reads the config file to determine the log level, but the childProcess does not. So the log level used in dmpWorker is always `debug`, regardless of the configuration options. In addition to polluting the logs, this is potentially a privacy issue, because `dmpWorker` logs the diffs of notes at the `debug` level, which will then enter the system logs. This commit fixes this by making `dmpWorker` send any messages back to the parent, who is responsible for logging. This also avoids any potential race conditions between the two loggers writing to the same output. Fixes #433 Signed-off-by: Dexter Chua <dec41@srcf.net>
This commit is contained in:
parent
370916e951
commit
efaa402dca
2 changed files with 27 additions and 12 deletions
|
@ -21,6 +21,7 @@ class Data {
|
|||
cacheKey
|
||||
error
|
||||
result
|
||||
level
|
||||
}
|
||||
|
||||
function createDmpWorker (): ChildProcess {
|
||||
|
@ -33,6 +34,10 @@ function createDmpWorker (): ChildProcess {
|
|||
}
|
||||
const cacheKey = data.cacheKey
|
||||
switch (data.msg) {
|
||||
case 'log':
|
||||
logger.log(data.level, data.result[0], ...data.result[1])
|
||||
// The cacheKey is a dummy value and we want to skip the delete line.
|
||||
return
|
||||
case 'error':
|
||||
dmpCallbackCache[cacheKey](data.error, null)
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue