Skip to content

Commit b339a50

Browse files
author
Igor Drobiazko
authored
Merge pull request #33 from elasticio/thread-logs
Using logger
2 parents 324482a + dfa4fe1 commit b339a50

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

lib/actions/splitOnJsonata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function processAction(msg, cfg) {
2020

2121
const results = [];
2222
split.forEach((elem) => results.push(elem));
23-
this.logger.debug('%s parts to emit found', results.length);
23+
this.logger.info('Splitting the incoming message into %s messages', results.length);
2424
results.forEach(async (result) => {
2525
if (result) {
2626
await this.emit('data', messages.newMessageWithBody(result));

package-lock.json

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
},
1818
"dependencies": {
1919
"@elastic.io/component-commons-library": "0.0.4",
20-
"debug": "2.6.3",
2120
"elasticio-node": "0.0.9",
2221
"elasticio-sailor-nodejs": "2.5.1",
2322
"lodash": "4.17.4"

split.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const debug = require('debug')('splitter');
21
const _ = require('lodash');
32
const { messages } = require('elasticio-node');
43

@@ -7,8 +6,8 @@ async function processAction(msg, conf) {
76
const splitting = conf.splitter || {};
87
const body = msg.body || {};
98

10-
debug('Received new message with body: %j', body);
11-
debug('Config: %j', conf);
9+
this.logger.debug('Received new message with body: %j', body);
10+
this.logger.debug('Config: %j', conf);
1211

1312
const split = splitting === '$' ? body : _.get(body, splitting);
1413

@@ -32,11 +31,11 @@ async function processAction(msg, conf) {
3231
if (_.isArray(split)) {
3332
split.forEach((elem) => results.push(elem));
3433
} else if (_.isObject(split)) {
35-
debug(`"${splitting}" is not an array. Returning the original object`);
34+
this.logger.debug(`"${splitting}" is not an array. Returning the original object`);
3635
results.push(split);
3736
}
3837

39-
debug('%s parts to emit found', results.length);
38+
this.logger.info('Splitting the incoming message into %s messages', results.length);
4039
results.forEach(async (result) => {
4140
if (result) {
4241
await this.emit('data', messages.newMessageWithBody(result));

0 commit comments

Comments
 (0)