I have to applications which import shared packages:
A frontend bundled for the browser with react-scripts
A nodejs backend
I'd like to move from console.log to log4js across both projects including the shared libraries. Ideally, I would create a log package that determines the runtime context, and initialize either log4js or log4js-node accordingly. Then, the logger would simply be imported pre-configured in all of my modules:
import log from log;
// This should just work because the logger is configured in the log package
log.info('foo');
Is this a valid design and are there examples of such implementation?
I have to applications which import shared packages:
I'd like to move from
console.log
to log4js across both projects including the shared libraries. Ideally, I would create a log package that determines the runtime context, and initialize either log4js or log4js-node accordingly. Then, the logger would simply be imported pre-configured in all of my modules:Is this a valid design and are there examples of such implementation?