clusteringBrowser.js 481 B

12345678910111213141516171819
  1. /* istanbul ignore file */
  2. // This is used in browsers only and is designed to allow the rest of
  3. // log4js to continue as if `clustering.js` is in use.
  4. const isMaster = () => true;
  5. const listeners = [];
  6. const sendToListeners = (logEvent) => {
  7. listeners.forEach((l) => l(logEvent));
  8. };
  9. module.exports = {
  10. onlyOnMaster: (fn, notMaster) => (isMaster() ? fn() : notMaster),
  11. isMaster,
  12. send: sendToListeners,
  13. onMessage: (listener) => {
  14. listeners.push(listener);
  15. },
  16. };