Skip to content

Commit 34ffc19

Browse files
committed
feat(lint): add some logs to debug on prod
1 parent 0ff55cf commit 34ffc19

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/lint/lint.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Module } from '@nestjs/common';
2+
import { LoggerModule } from 'nestjs-pino';
23
import { LintService } from './lint.service';
34

45
@Module({
6+
imports: [LoggerModule.forRoot()],
57
providers: [LintService],
68
})
79
export class LintModule {}

src/lint/lint.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { Injectable, InternalServerErrorException } from '@nestjs/common';
66
import child_process from 'child_process';
77
import fs from 'fs';
8+
import { Logger } from 'nestjs-pino';
89
import * as uuid from 'uuid';
910
import YAML from 'yaml';
1011
import { LintErrorDTO } from './dto/lint-error.dto';
@@ -14,6 +15,8 @@ import { ConvertToPylintOutput } from './linters/pylint';
1415

1516
@Injectable()
1617
export class LintService {
18+
constructor(private readonly logger: Logger) {}
19+
1720
lintPython3(code: string): LintResultDTO {
1821
const result = child_process.spawnSync(
1922
'pylint',
@@ -24,13 +27,14 @@ export class LintService {
2427
);
2528

2629
if (result.error) {
27-
throw new InternalServerErrorException();
30+
throw new InternalServerErrorException('Failed to run pylint');
2831
}
2932

3033
try {
3134
let output = result.output.toString();
3235
output = output.substring(1);
3336
output = output.substring(0, output.length - 1);
37+
this.logger.log(output);
3438
const pylintOutput = ConvertToPylintOutput.toPylintOutput(output);
3539
if (pylintOutput) {
3640
/*
@@ -69,7 +73,7 @@ export class LintService {
6973
};
7074
}
7175
} catch (e) {
72-
throw new InternalServerErrorException();
76+
throw new InternalServerErrorException(e);
7377
}
7478

7579
throw new InternalServerErrorException();
@@ -99,6 +103,7 @@ export class LintService {
99103
let output = result.output.toString();
100104
output = output.substring(1);
101105
output = output.substring(0, output.length - 1);
106+
this.logger.log(output);
102107
const lintOuput =
103108
ConvertToGolangCILintOutput.toGolangCILintOutput(output);
104109
if (lintOuput) {
@@ -185,6 +190,7 @@ export class LintService {
185190
if (fs.existsSync(outputPath)) {
186191
const file = fs.readFileSync(`${path}.yaml`, 'utf8');
187192
const fixes: any = YAML.parse(file);
193+
this.logger.log(fixes);
188194

189195
if (fixes) {
190196
/*

src/submissions/submissions.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import { IsNull, Not, Repository } from 'typeorm';
1111
import { Benchmark } from '../benchmarks/benchmark.entity';
1212
import { BenchmarkService } from '../benchmarks/benchmark.service';
1313
import { BenchmarkIdDto } from '../benchmarks/dto/benchmarkId.dto';
14+
import { CyclomaticComplexity } from '../code-quality/complexity/CyclomaticComplexity';
15+
import { CodeTokenizer } from '../code-quality/tokenizer/CodeTokenizer';
1416
import { HashService } from '../hash/hash.service';
1517
import { User } from '../users/user.entity';
1618
import { FindLastSubmissionByLanguageDTO } from './dto/find-last-submission-by-language.dto';
1719
import { FindSubmissionDTO } from './dto/find-submission.dto';
1820
import { InsertSubmissionDTO } from './dto/insert-submission-dto';
1921
import { JobStatusDTO } from './dto/job-status.dto';
2022
import { Submission } from './submission.entity';
21-
import { CodeTokenizer } from '../code-quality/tokenizer/CodeTokenizer';
22-
import { CyclomaticComplexity } from '../code-quality/complexity/CyclomaticComplexity';
2323

2424
@Injectable()
2525
export class SubmissionsService {

0 commit comments

Comments
 (0)