Skip to content

Commit 9442658

Browse files
committed
feat(logs): Refactor logs for list_item_hunter
1 parent 4a681a4 commit 9442658

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/lib/list_item_hunter.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const list_item_hunter = function () {
77
const smh = require('./style_modifier_hunter');
88
const jsonCopy = require('./json_copy');
99
const Pattern = require('./object_factory').Pattern;
10+
const logger = require('./log');
1011

1112
const pattern_assembler = new pa();
1213
const style_modifier_hunter = new smh();
@@ -19,9 +20,7 @@ const list_item_hunter = function () {
1920
if (matches !== null) {
2021
matches.forEach(function (liMatch) {
2122

22-
if (patternlab.config.debug) {
23-
console.log('found listItem of size ' + liMatch + ' inside ' + pattern.patternPartial);
24-
}
23+
logger.debug(`found listItem of size ${liMatch} inside ${pattern.patternPartial}`);
2524

2625
//find the boundaries of the block
2726
const loopNumberString = liMatch.split('.')[1].split('}')[0].trim();
@@ -32,9 +31,8 @@ const list_item_hunter = function () {
3231
const repeatedBlockTemplate = [];
3332
let repeatedBlockHtml = '';
3433
for (let i = 0; i < items.indexOf(loopNumberString); i++) {
35-
if (patternlab.config.debug) {
36-
console.log('list item(s) in pattern', pattern.patternPartial, 'adding', patternBlock, 'to repeatedBlockTemplate');
37-
}
34+
35+
logger.debug(`list item(s) in pattern ${pattern.patternPartial}, adding ${patternBlock} to repeatedBlockTemplate`);
3836
repeatedBlockTemplate.push(patternBlock);
3937
}
4038

@@ -43,8 +41,8 @@ const list_item_hunter = function () {
4341
try {
4442
listData = jsonCopy(patternlab.listitems, 'config.paths.source.data listitems');
4543
} catch (err) {
46-
console.log('There was an error parsing JSON for ' + pattern.relPath);
47-
console.log(err);
44+
logger.warning(`There was an error parsing JSON for ${pattern.relPath}`);
45+
logger.warning(err);
4846
}
4947

5048
listData = _.merge(listData, pattern.listitems);
@@ -64,8 +62,8 @@ const list_item_hunter = function () {
6462
globalData = jsonCopy(patternlab.data, 'config.paths.source.data global data');
6563
localData = jsonCopy(pattern.jsonFileData, `${pattern.patternPartial} data`);
6664
} catch (err) {
67-
console.log('There was an error parsing JSON for ' + pattern.relPath);
68-
console.log(err);
65+
logger.warning(`There was an error parsing JSON for ${pattern.relPath}`);
66+
logger.warning(err);
6967
}
7068

7169
let allData = _.merge(globalData, localData);
@@ -89,8 +87,8 @@ const list_item_hunter = function () {
8987
cleanPartialPattern = JSON.parse(JSON.stringify(partialPattern));
9088
cleanPartialPattern = jsonCopy(partialPattern, `partial pattern ${partialName}`);
9189
} catch (err) {
92-
console.log('There was an error parsing JSON for ' + pattern.relPath);
93-
console.log(err);
90+
logger.warning(`There was an error parsing JSON for ${pattern.relPath}`);
91+
logger.warning(err);
9492
}
9593

9694
//if we retrieved a pattern we should make sure that its extendedTemplate is reset. looks to fix #356

0 commit comments

Comments
 (0)