Skip to content

Commit

Permalink
feat: add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Nov 14, 2024
1 parent 20a830a commit 2f6de5b
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 14 deletions.
15 changes: 15 additions & 0 deletions audit/apps/audit/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createLogger, format, transports } from 'winston';

const logger = createLogger({
level: process.env.LEVEL ?? 'error',
});

if (process.env.NODE_ENV !== 'production') {
logger.add(
new transports.Console({
format: format.simple(),
})
);
}

export default logger;
4 changes: 2 additions & 2 deletions audit/apps/audit/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FileSystemParser } from './parsers/file-system-parser';
import { FileSystemChecker } from './checkers/sync/file-system-checker';
import { HttpChecker } from './checkers/async/http-system-checker';
import yoctoSpinner from 'yocto-spinner';
import logger from './logger';

program.name('audit').version('0.0.0');

Expand Down Expand Up @@ -41,7 +42,6 @@ program

const fileSystemParser = new FileSystemParser();
audit.parsers = fileSystemParser.parse('.');

if (!config['only-parser']) {
const fileSystemChecker = new FileSystemChecker(audit.parsers);
audit.syncChecks = fileSystemChecker.check();
Expand All @@ -52,6 +52,7 @@ program
try {
audit.asyncChecks = {};
for (const url of config.urls) {
logger.info(`Starting auditing with async checks: ${url}`);
audit.asyncChecks[url] = await httpChecker.check(url);
}
} catch (e) {
Expand All @@ -64,5 +65,4 @@ program
console.log(JSON.stringify(audit));
});


program.parse();
Loading

0 comments on commit 2f6de5b

Please sign in to comment.