Closed didemkaraaslan closed 3 years ago
You need to inject the logger as a dependency wherever you use it instead of pulling it from globals. You can write something like this:
# server/main.js
import { myFunctionNeedingALogger } from "api/methods";
const logger = global.logger = new ServerLogger(strategy, WebApp);
myFunctionNeedingALogger(logger);
# same for client/main.js
That way, the function used isomorphically in imports/api/methods receives the logger as a parameter depending on the environment.
No answer in over 1 year, assuming fixed.
So I have
client/main.js
server/main.js
My question is how do I use logger inside /imports/api/methods.js file?
imports/api/methods.js
global.logger.error("error"); // global.logger is undefined here..