Change logger to log

This commit is contained in:
harshilparmar
2021-02-06 15:56:05 +05:30
parent edd7bc7197
commit 7019a1149d
41 changed files with 366 additions and 376 deletions

View File

@@ -3,7 +3,7 @@ import utils from '../../utils';
import * as configApi from '../../config';
import common from '../common/common';
import mermaidAPI from '../../mermaidAPI';
import { logger } from '../../logger';
import { log } from '../../logger';
const MERMAID_DOM_ID_PREFIX = 'flowchart-';
let vertexCounter = 0;
@@ -117,7 +117,7 @@ export const addSingleLink = function(_start, _end, type, linktext) {
let end = _end;
// if (start[0].match(/\d/)) start = MERMAID_DOM_ID_PREFIX + start;
// if (end[0].match(/\d/)) end = MERMAID_DOM_ID_PREFIX + end;
// logger.info('Got edge...', start, end);
// log.info('Got edge...', start, end);
const edge = { start: start, end: end, type: undefined, text: '' };
linktext = type.text;
@@ -457,7 +457,7 @@ export const addSubGraph = function(_id, list, _title) {
nodeList = uniq(nodeList.concat.apply(nodeList, list));
if (version === 'gen-1') {
logger.warn('LOOKING UP');
log.warn('LOOKING UP');
for (let i = 0; i < nodeList.length; i++) {
nodeList[i] = lookUpDomId(nodeList[i]);
}
@@ -470,7 +470,7 @@ export const addSubGraph = function(_id, list, _title) {
subCount = subCount + 1;
const subGraph = { id: id, nodes: nodeList, title: title.trim(), classes: [] };
logger.info('Adding', subGraph.id, subGraph.nodes);
log.info('Adding', subGraph.id, subGraph.nodes);
/**
* Deletes an id from all subgraphs

View File

@@ -7,7 +7,7 @@ import { getConfig } from '../../config';
import { render } from '../../dagre-wrapper/index.js';
import addHtmlLabel from 'dagre-d3/lib/label/add-html-label.js';
import { logger } from '../../logger';
import { log } from '../../logger';
import common from '../common/common';
import { interpolateToCurve, getStylesFromArray, configureSvgSize } from '../../utils';
@@ -151,7 +151,7 @@ export const addVertices = function(vert, g, svgId) {
padding: getConfig().flowchart.padding
});
logger.info('setNode', {
log.info('setNode', {
labelStyle: styles.labelStyle,
shape: _shape,
labelText: vertexText,
@@ -306,7 +306,7 @@ export const addEdges = function(edges, g) {
* @returns {object} classDef styles
*/
export const getClasses = function(text) {
logger.info('Extracting classes');
log.info('Extracting classes');
flowDb.clear();
const parser = flow.parser;
parser.yy = flowDb;
@@ -328,7 +328,7 @@ export const getClasses = function(text) {
*/
export const draw = function(text, id) {
logger.info('Drawing flowchart');
log.info('Drawing flowchart');
flowDb.clear();
flowDb.setGen('gen-2');
const parser = flow.parser;
@@ -338,7 +338,7 @@ export const draw = function(text, id) {
// try {
parser.parse(text);
// } catch (err) {
// logger.debug('Parsing failed');
// log.debug('Parsing failed');
// }
// Fetch the default direction, use TD if none was found
@@ -369,10 +369,10 @@ export const draw = function(text, id) {
let subG;
const subGraphs = flowDb.getSubGraphs();
logger.info('Subgraphs - ', subGraphs);
log.info('Subgraphs - ', subGraphs);
for (let i = subGraphs.length - 1; i >= 0; i--) {
subG = subGraphs[i];
logger.info('Subgraph - ', subG);
log.info('Subgraph - ', subG);
flowDb.addVertex(subG.id, subG.title, 'group', undefined, subG.classes);
}
@@ -381,7 +381,7 @@ export const draw = function(text, id) {
const edges = flowDb.getEdges();
logger.info(edges);
log.info(edges);
let i = 0;
for (i = subGraphs.length - 1; i >= 0; i--) {
// for (let i = 0; i < subGraphs.length; i++) {
@@ -390,7 +390,7 @@ export const draw = function(text, id) {
selectAll('cluster').append('text');
for (let j = 0; j < subG.nodes.length; j++) {
logger.info('Setting up subgraphs', subG.nodes[j], subG.id);
log.info('Setting up subgraphs', subG.nodes[j], subG.id);
g.setParent(subG.nodes[j], subG.id);
}
}
@@ -412,7 +412,7 @@ export const draw = function(text, id) {
const svgBounds = svg.node().getBBox();
const width = svgBounds.width + padding * 2;
const height = svgBounds.height + padding * 2;
logger.debug(
log.debug(
`new ViewBox 0 0 ${width} ${height}`,
`translate(${padding - g._label.marginx}, ${padding - g._label.marginy})`
);

View File

@@ -7,7 +7,7 @@ import { getConfig } from '../../config';
import dagreD3 from 'dagre-d3';
import addHtmlLabel from 'dagre-d3/lib/label/add-html-label.js';
import { logger } from '../../logger';
import { log } from '../../logger';
import common from '../common/common';
import { interpolateToCurve, getStylesFromArray, configureSvgSize } from '../../utils';
import flowChartShapes from './flowChartShapes';
@@ -133,7 +133,7 @@ export const addVertices = function(vert, g, svgId) {
_shape = 'rect';
}
// Add the node
logger.warn('Adding node', vertex.id, vertex.domId);
log.warn('Adding node', vertex.id, vertex.domId);
g.setNode(flowDb.lookUpDomId(vertex.id), {
labelType: 'svg',
labelStyle: styles.labelStyle,
@@ -260,7 +260,7 @@ export const addEdges = function(edges, g) {
* @returns {object} classDef styles
*/
export const getClasses = function(text) {
logger.info('Extracting classes');
log.info('Extracting classes');
flowDb.clear();
try {
const parser = flow.parser;
@@ -280,7 +280,7 @@ export const getClasses = function(text) {
* @param id
*/
export const draw = function(text, id) {
logger.info('Drawing flowchart');
log.info('Drawing flowchart');
flowDb.clear();
flowDb.setGen('gen-1');
const parser = flow.parser;
@@ -290,7 +290,7 @@ export const draw = function(text, id) {
// try {
parser.parse(text);
// } catch (err) {
// logger.debug('Parsing failed');
// log.debug('Parsing failed');
// }
// Fetch the default direction, use TD if none was found
@@ -328,7 +328,7 @@ export const draw = function(text, id) {
// Fetch the verices/nodes and edges/links from the parsed graph definition
const vert = flowDb.getVertices();
logger.warn('Get vertices', vert);
log.warn('Get vertices', vert);
const edges = flowDb.getEdges();
@@ -339,7 +339,7 @@ export const draw = function(text, id) {
selectAll('cluster').append('text');
for (let j = 0; j < subG.nodes.length; j++) {
logger.warn(
log.warn(
'Setting subgraph',
subG.nodes[j],
flowDb.lookUpDomId(subG.nodes[j]),
@@ -400,7 +400,7 @@ export const draw = function(text, id) {
const svg = select(`[id="${id}"]`);
svg.attr('xmlns:xlink', 'http://www.w3.org/1999/xlink');
logger.warn(g);
log.warn(g);
// Run the renderer. This is what draws the final graph.
const element = select('#' + id + ' g');
@@ -419,7 +419,7 @@ export const draw = function(text, id) {
// Ensure the viewBox includes the whole svgBounds area with extra space for padding
const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;
logger.debug(`viewBox ${vBox}`);
log.debug(`viewBox ${vBox}`);
svg.attr('viewBox', vBox);
// Index nodes