expose the index of the metadata log processor
This commit is contained in:
parent
206de52ee8
commit
ce847700c4
@ -85,19 +85,19 @@ var handleCommand = function (meta, line) {
|
|||||||
|
|
||||||
Meta.createLineHandler = function (ref, errorHandler) {
|
Meta.createLineHandler = function (ref, errorHandler) {
|
||||||
ref.meta = {};
|
ref.meta = {};
|
||||||
|
ref.index = 0;
|
||||||
|
|
||||||
var index = 0;
|
|
||||||
return function (err, line) {
|
return function (err, line) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return void errorHandler('METADATA_HANDLER_LINE_ERR', {
|
return void errorHandler('METADATA_HANDLER_LINE_ERR', {
|
||||||
error: err,
|
error: err,
|
||||||
index: index,
|
index: ref.index,
|
||||||
line: JSON.stringify(line),
|
line: JSON.stringify(line),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(line)) {
|
if (Array.isArray(line)) {
|
||||||
index++;
|
ref.index++;
|
||||||
try {
|
try {
|
||||||
handleCommand(ref.meta, line);
|
handleCommand(ref.meta, line);
|
||||||
} catch (err2) {
|
} catch (err2) {
|
||||||
@ -109,8 +109,8 @@ Meta.createLineHandler = function (ref, errorHandler) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index === 0 && typeof(line) === 'object') {
|
if (ref.index === 0 && typeof(line) === 'object') {
|
||||||
index++;
|
ref.index++;
|
||||||
// special case!
|
// special case!
|
||||||
ref.meta = line;
|
ref.meta = line;
|
||||||
return;
|
return;
|
||||||
@ -118,7 +118,7 @@ Meta.createLineHandler = function (ref, errorHandler) {
|
|||||||
|
|
||||||
errorHandler("METADATA_HANDLER_WEIRDLINE", {
|
errorHandler("METADATA_HANDLER_WEIRDLINE", {
|
||||||
line: line,
|
line: line,
|
||||||
index: index++,
|
index: ref.index++,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user