Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

debug.js 606B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const util = require('util');
  3. const fs = require('fs')
  4. /**
  5. * Boolean indicating if debug mode is enabled.
  6. *
  7. * @type {boolean}
  8. */
  9. const IS_DEBUG = process.env.SPAWN_WRAP_DEBUG === '1'
  10. /**
  11. * If debug is enabled, write message to stderr.
  12. *
  13. * If debug is disabled, no message is written.
  14. */
  15. function debug(...args) {
  16. if (!IS_DEBUG) {
  17. return;
  18. }
  19. const prefix = `SW ${process.pid}: `
  20. const data = util.format(...args).trim()
  21. const message = data.split('\n').map(line => `${prefix}${line}\n`).join('')
  22. fs.writeSync(2, message)
  23. }
  24. module.exports = {
  25. IS_DEBUG,
  26. debug,
  27. }