Browse Source

TypeError: console.debug is not a function in node 6 #360 (#361)

pull/1/head
rozetko 6 years ago committed by GitHub
parent
commit
6c85d0292c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      server/src/config.ts
  2. 12
      server/src/controllers/analytics_controller.ts
  3. 2
      server/src/services/alert_service.ts
  4. 4
      server/src/services/data_puller.ts

2
server/src/config.ts

@ -64,7 +64,7 @@ function getPackageVersion() {
let packageJson: any = getJsonDataSync(packageFile);
return packageJson.version;
} else {
console.debug(`Can't find package file ${packageFile}`);
console.log(`Can't find package file ${packageFile}`);
return null;
}
}

12
server/src/controllers/analytics_controller.ts

@ -117,7 +117,7 @@ async function query(analyticUnit: AnalyticUnit.AnalyticUnit, detector: Analytic
to: now
};
}
console.debug(`query time range: from ${new Date(range.from)} to ${new Date(range.to)}`);
console.log(`query time range: from ${new Date(range.from)} to ${new Date(range.to)}`);
let panelUrl;
if(GRAFANA_URL !== null) {
@ -160,7 +160,7 @@ function getQueryRangeForLearningBySegments(segments: Segment.Segment[]) {
}
export async function runLearning(id: AnalyticUnit.AnalyticUnitId) {
console.debug('learning started...');
console.log('learning started...');
try {
let analyticUnit = await AnalyticUnit.findById(id);
@ -206,7 +206,7 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId) {
id, AnalyticsTaskType.LEARN, taskPayload
);
AnalyticUnit.setStatus(id, AnalyticUnit.AnalyticUnitStatus.LEARNING);
console.debug(`run task, id:${id}`);
console.log(`run task, id:${id}`);
let result = await runTask(task);
if(result.status !== AnalyticUnit.AnalyticUnitStatus.SUCCESS) {
throw new Error(result.error);
@ -245,7 +245,7 @@ export async function runDetect(id: AnalyticUnit.AnalyticUnitId) {
AnalyticsTaskType.DETECT,
{ detector, analyticUnitType, lastDetectionTime: unit.lastDetectionTime, data, cache: oldCache }
);
console.debug(`run task, id:${id}`);
console.log(`run task, id:${id}`);
let result = await runTask(task);
if(result.status === AnalyticUnit.AnalyticUnitStatus.FAILED) {
throw new Error(result.error);
@ -302,7 +302,7 @@ async function processDetectionResult(analyticUnitId: AnalyticUnit.AnalyticUnitI
`Missing lastDetectionTime in result or it is corrupted: ${JSON.stringify(detectionResult)}`
);
}
console.debug(`got detection result for ${analyticUnitId} with ${detectionResult.segments.length} segments`);
console.log(`got detection result for ${analyticUnitId} with ${detectionResult.segments.length} segments`);
const sortedSegments: {from, to}[] = _.sortBy(detectionResult.segments, 'from');
const segments = sortedSegments.map(
@ -323,7 +323,7 @@ async function processDetectionResult(analyticUnitId: AnalyticUnit.AnalyticUnitI
if(_.isEmpty(segments)) {
reasons.push('segments empty');
}
console.debug(`skip sending webhook for ${analyticUnit.id}, ${reasons.join(', ')}`);
console.log(`skip sending webhook for ${analyticUnit.id}, ${reasons.join(', ')}`);
}
return {
lastDetectionTime: detectionResult.lastDetectionTime,

2
server/src/services/alert_service.ts

@ -44,7 +44,7 @@ class ThresholdAlert extends Alert {
if(segment.from - this.lastOccurence > this.EXPIRE_PERIOD_MS) {
if(this.enabled) {
console.debug(`time between threshold occurences ${segment.from - this.lastOccurence}ms, send alert`);
console.log(`time between threshold occurences ${segment.from - this.lastOccurence}ms, send alert`);
sendWebhook(this.analyticUnit.name, segment);
}
}

4
server/src/services/data_puller.ts

@ -83,7 +83,7 @@ export class DataPuller {
}
private async _runAnalyticUnitPuller(analyticUnit: AnalyticUnit.AnalyticUnit) {
console.debug(`run data puller for analytic unit ${analyticUnit.id}`);
console.log(`run data puller for analytic unit ${analyticUnit.id}`);
// TODO: lastDetectionTime can be in ns
const time = analyticUnit.lastDetectionTime + 1 || Date.now();
this._unitTimes[analyticUnit.id] = time;
@ -127,7 +127,7 @@ export class DataPuller {
const getData = async () => {
if(!this.analyticsService.ready) {
console.debug(`data generator: analytic service not ready, return empty result while wait service`);
console.log(`data generator: analytic service not ready, return empty result while wait service`);
return {
columns: [],
values: []

Loading…
Cancel
Save