Closed roypa closed 2 years ago
I have run into the same thing. I use multiple talkback.requestHandler
.
The problem seems to be that for every time a new requestHandler
or server is created there is a line initializeLogger
https://github.com/ijpiantanida/talkback/blob/ba5b4ebd1b4518e6f7bc34ad69e6aa8a6ec4bcbe/src/talkback-factory.ts#L10-L16
which modifies a global logger
object to override logger.log
with an instance of ConsoleLogger
instead of NoopLogger
. https://github.com/ijpiantanida/talkback/blob/ba5b4ebd1b4518e6f7bc34ad69e6aa8a6ec4bcbe/src/logger.ts#L67 and passes in the options of the current handler! So the logger becomes tied to the current handler.
The logger has a method formatMessage
that takes only two arguments message
and level
. I have been overriding formatMessage myself to tweak its output, but I didn't understand why it printed for the wrong handler.
When formatMessage
is called there is nothing to differentiate between different handlers so it is not enough to patch it.
Great call @scmx, the global logger was definitely a problem.
This should be fixed in v3.0.2
I start multiple Talkback servers in the same Node script, each handling the requests to a specific backend server.
The code looks something like this:
This works very well. The only issue we have with this, is that the log output from each of the servers does not reflect the server name provided in the options. The log output from both servers have the same name in the log line. This is always the name of the last server started.
For example when the the summary is being printed from these two servers, it looks like this:
Any idea why this is happening?