stritti / log4js

Log4js - The Logging Framework for JavaScript with no runtime dependencies
https://stritti.github.io/log4js/
Apache License 2.0
449 stars 57 forks source link

Share between browser and node #45

Open fredfortier opened 4 years ago

fredfortier commented 4 years ago

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:

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?