Expose logger implemtation to modules for testing #63
Labels
enhancement
New feature or request
pr wanted
The best way to get this implemented is to submit a PR!
Is this a feature relevant to companion itself, and not a module?
Is there an existing issue for this?
Describe the feature
Hello,
I would like to log errors in my logic that is not related to companion and main problem is that logger (winston) is defined in companion itself.
There are two different logs
Companion log, is OK, because I am in "module code" then, creating presets, actions, etc and have access to InstanceBase.
Logging Logging works because module should be either mocked or initialized for tests to work (infrastructure tests).
Now, this is my module logs that I am talking about.
My logic, like API calls, are not by any way related to companion and do not require it (actually, don't want it in global tab).
Let's take example from Jest.
An ES6 Class Example
With logger, I want to abstract from console and write
And set log level once from module config in main.js
This is problematic, because of logger dependency from module base.
I want to propose to declare logger (winston) "somewhere else" :) And let developers use it, instead of controller, will all functions and overloads.
When running as module, it should take default implementation with transports. Something like CompanionTransport and MyModuleTransport.
Basically, I want logger.js in my repo and use logger from there.
Probably, something like that
https://github.com/bitfocus/companion/blob/1b6dfc49a2816568f68f43bfe360d6bcd49817de/lib/Log/Controller.js#L95C13-L95C13
May be related:
bitfocus/companion#2420
LogController
Usecases
Development and debugging mostly.
The text was updated successfully, but these errors were encountered: