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.

CustomConsole.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _assert() {
  7. const data = _interopRequireDefault(require('assert'));
  8. _assert = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _console() {
  14. const data = require('console');
  15. _console = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _util() {
  21. const data = require('util');
  22. _util = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _chalk() {
  28. const data = _interopRequireDefault(require('chalk'));
  29. _chalk = function () {
  30. return data;
  31. };
  32. return data;
  33. }
  34. function _jestUtil() {
  35. const data = require('jest-util');
  36. _jestUtil = function () {
  37. return data;
  38. };
  39. return data;
  40. }
  41. function _interopRequireDefault(obj) {
  42. return obj && obj.__esModule ? obj : {default: obj};
  43. }
  44. function _defineProperty(obj, key, value) {
  45. if (key in obj) {
  46. Object.defineProperty(obj, key, {
  47. value: value,
  48. enumerable: true,
  49. configurable: true,
  50. writable: true
  51. });
  52. } else {
  53. obj[key] = value;
  54. }
  55. return obj;
  56. }
  57. class CustomConsole extends _console().Console {
  58. constructor(stdout, stderr, formatBuffer = (_type, message) => message) {
  59. super(stdout, stderr);
  60. _defineProperty(this, '_stdout', void 0);
  61. _defineProperty(this, '_stderr', void 0);
  62. _defineProperty(this, '_formatBuffer', void 0);
  63. _defineProperty(this, '_counters', {});
  64. _defineProperty(this, '_timers', {});
  65. _defineProperty(this, '_groupDepth', 0);
  66. _defineProperty(this, 'Console', _console().Console);
  67. this._stdout = stdout;
  68. this._stderr = stderr;
  69. this._formatBuffer = formatBuffer;
  70. }
  71. _log(type, message) {
  72. (0, _jestUtil().clearLine)(this._stdout);
  73. super.log(
  74. this._formatBuffer(type, ' '.repeat(this._groupDepth) + message)
  75. );
  76. }
  77. _logError(type, message) {
  78. (0, _jestUtil().clearLine)(this._stderr);
  79. super.error(
  80. this._formatBuffer(type, ' '.repeat(this._groupDepth) + message)
  81. );
  82. }
  83. assert(value, message) {
  84. try {
  85. (0, _assert().default)(value, message);
  86. } catch (error) {
  87. this._logError('assert', error.toString());
  88. }
  89. }
  90. count(label = 'default') {
  91. if (!this._counters[label]) {
  92. this._counters[label] = 0;
  93. }
  94. this._log(
  95. 'count',
  96. (0, _util().format)(`${label}: ${++this._counters[label]}`)
  97. );
  98. }
  99. countReset(label = 'default') {
  100. this._counters[label] = 0;
  101. }
  102. debug(firstArg, ...args) {
  103. this._log('debug', (0, _util().format)(firstArg, ...args));
  104. }
  105. dir(firstArg, options = {}) {
  106. const representation = (0, _util().inspect)(firstArg, options);
  107. this._log('dir', (0, _util().formatWithOptions)(options, representation));
  108. }
  109. dirxml(firstArg, ...args) {
  110. this._log('dirxml', (0, _util().format)(firstArg, ...args));
  111. }
  112. error(firstArg, ...args) {
  113. this._logError('error', (0, _util().format)(firstArg, ...args));
  114. }
  115. group(title, ...args) {
  116. this._groupDepth++;
  117. if (title || args.length > 0) {
  118. this._log(
  119. 'group',
  120. _chalk().default.bold((0, _util().format)(title, ...args))
  121. );
  122. }
  123. }
  124. groupCollapsed(title, ...args) {
  125. this._groupDepth++;
  126. if (title || args.length > 0) {
  127. this._log(
  128. 'groupCollapsed',
  129. _chalk().default.bold((0, _util().format)(title, ...args))
  130. );
  131. }
  132. }
  133. groupEnd() {
  134. if (this._groupDepth > 0) {
  135. this._groupDepth--;
  136. }
  137. }
  138. info(firstArg, ...args) {
  139. this._log('info', (0, _util().format)(firstArg, ...args));
  140. }
  141. log(firstArg, ...args) {
  142. this._log('log', (0, _util().format)(firstArg, ...args));
  143. }
  144. time(label = 'default') {
  145. if (this._timers[label]) {
  146. return;
  147. }
  148. this._timers[label] = new Date();
  149. }
  150. timeEnd(label = 'default') {
  151. const startTime = this._timers[label];
  152. if (startTime) {
  153. const endTime = new Date().getTime();
  154. const time = endTime - startTime.getTime();
  155. this._log(
  156. 'time',
  157. (0, _util().format)(`${label}: ${(0, _jestUtil().formatTime)(time)}`)
  158. );
  159. delete this._timers[label];
  160. }
  161. }
  162. timeLog(label = 'default', ...data) {
  163. const startTime = this._timers[label];
  164. if (startTime) {
  165. const endTime = new Date();
  166. const time = endTime.getTime() - startTime.getTime();
  167. this._log(
  168. 'time',
  169. (0, _util().format)(
  170. `${label}: ${(0, _jestUtil().formatTime)(time)}`,
  171. ...data
  172. )
  173. );
  174. }
  175. }
  176. warn(firstArg, ...args) {
  177. this._logError('warn', (0, _util().format)(firstArg, ...args));
  178. }
  179. getBuffer() {
  180. return undefined;
  181. }
  182. }
  183. exports.default = CustomConsole;