Skip to content

Commit

Permalink
feat(judger-agent): add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Apr 2, 2024
1 parent f074caf commit 856bb81
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/sub-app/judger-agent/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/sub-app/judger-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"devDependencies": {
"@types/adm-zip": "^0.4.33",
"@types/debug": "^4.1.12",
"@types/lodash": "4.14.151",
"@types/microtime": "^2.1.2",
"@types/node": "16.11.7",
Expand Down
9 changes: 7 additions & 2 deletions src/sub-app/judger-agent/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Axios from 'axios';
import type { AxiosInstance } from 'axios';
import PCancelable from 'p-cancelable';
import microtime from 'microtime';
import debug from 'debug';
import config from '../config';
import { judgerAgentLogger } from '../utils/logger';
import { river } from '../proto/river';
Expand All @@ -14,6 +15,7 @@ import { convertRiverResultToOJ } from '../utils';
import { getProblemDataResult } from '../utils/judger';

const logger = judgerAgentLogger;
const dbg = debug('onlinejudge3:judger-agent:JudgerService');

export interface IJudgeOptions {
judgeInfoId: number;
Expand Down Expand Up @@ -86,13 +88,15 @@ export class JudgerService extends EventEmitter {

private async callbackJudge(judgeInfoId: number, solutionId: number, data: any) {
try {
const res = await this.ojApiInstance.post('/callbackJudge', {
const req = {
judgeInfoId,
solutionId,
judgerId: this.judgerId,
eventTimestampUs: microtime.now(),
data,
});
};
dbg('callback judge: %O', req);
const res = await this.ojApiInstance.post('/callbackJudge', req);
return !!res.data.success;
} catch (e) {
logger.warn('callback judge error:', judgeInfoId, JSON.stringify(data), e.message);
Expand Down Expand Up @@ -192,6 +196,7 @@ export class JudgerService extends EventEmitter {
});

const jResult = await call.run();
dbg('judge result: %O', jResult);
this.onAbortPoint();
logger.info(`${loggerPrefix} done`, JSON.stringify(jResult));
this.emit('active');
Expand Down

0 comments on commit 856bb81

Please sign in to comment.