source: trip-planner-front/node_modules/@angular-devkit/core/src/logger/indent.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.IndentLogger = void 0;
11const operators_1 = require("rxjs/operators");
12const logger_1 = require("./logger");
13/**
14 * Keep an map of indentation => array of indentations based on the level.
15 * This is to optimize calculating the prefix based on the indentation itself. Since most logs
16 * come from similar levels, and with similar indentation strings, this will be shared by all
17 * loggers. Also, string concatenation is expensive so performing concats for every log entries
18 * is expensive; this alleviates it.
19 */
20const indentationMap = {};
21class IndentLogger extends logger_1.Logger {
22 constructor(name, parent = null, indentation = ' ') {
23 super(name, parent);
24 indentationMap[indentation] = indentationMap[indentation] || [''];
25 const indentMap = indentationMap[indentation];
26 this._observable = this._observable.pipe(operators_1.map((entry) => {
27 const l = entry.path.filter((x) => !!x).length;
28 if (l >= indentMap.length) {
29 let current = indentMap[indentMap.length - 1];
30 while (l >= indentMap.length) {
31 current += indentation;
32 indentMap.push(current);
33 }
34 }
35 entry.message = indentMap[l] + entry.message.split(/\n/).join('\n' + indentMap[l]);
36 return entry;
37 }));
38 }
39}
40exports.IndentLogger = IndentLogger;
Note: See TracBrowser for help on using the repository browser.