Skip to content

Commit

Permalink
Merge pull request #49 from Virus288/fix/logger
Browse files Browse the repository at this point in the history
Fix: Moved logging to npm package, updated dependencies
  • Loading branch information
Virus288 authored Jan 13, 2025
2 parents 12308b1 + 0822823 commit fd1d40f
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 450 deletions.
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
"test:db": "cross-env NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --runInBand --config __tests__/jest.config.db.ts"
},
"dependencies": {
"chalk": "5.4.1",
"cors": "^2.8.5",
"express": "4.21.2",
"express-rate-limit": "^7.4.1",
"helmet": "^8.0.0",
"simpl-loggar": "^0.5.3",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"winston": "3.17.0",
"winston-daily-rotate-file": "5.0.0"
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@eslint/compat": "^1.2.2",
Expand All @@ -42,16 +40,16 @@
"@types/express": "5.0.0",
"@types/express-rate-limit": "^6.0.2",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "22.10.5",
"@types/node": "22.10.6",
"@types/supertest": "^6.0.2",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.6",
"@typescript-eslint/eslint-plugin": "8.19.1",
"@typescript-eslint/parser": "8.19.1",
"@typescript-eslint/eslint-plugin": "8.20.0",
"@typescript-eslint/parser": "8.20.0",
"concurrently": "^9.0.1",
"cross-env": "7.0.3",
"eslint": "9.17.0",
"eslint-config-prettier": "9.1.0",
"eslint": "9.18.0",
"eslint-config-prettier": "10.0.1",
"eslint-plugin-check-file": "2.8.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jest": "28.10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/connections/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from 'express';
import Log from 'simpl-loggar';
import Middleware from './middleware.js';
import AppRouter from './router.js';
import getConfig from '../../tools/configLoader.js';
import Log from '../../tools/logger/index.js';
import http from 'http';

export default class Router {
Expand Down
8 changes: 2 additions & 6 deletions src/connections/router/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import cors from 'cors';
import express from 'express';
import helmet from 'helmet';
import Log from 'simpl-loggar';
import * as errors from '../../errors/index.js';
import getConfig from '../../tools/configLoader.js';
import Log from '../../tools/logger/index.js';
import errLogger from '../../tools/logger/logger.js';
import type { IFullError } from '../../types/index.js';
import type { IResponse } from '../../types/requests.js';
import type { Express } from 'express';
Expand Down Expand Up @@ -103,10 +102,7 @@ export default class Middleware {
generateErrHandler(app: Express): void {
app.use(
(err: express.Errback | IFullError, req: express.Request, res: express.Response, _next: express.NextFunction) => {
errLogger
.error('Caught new generic error')
.error(`Caused by ${req.ip ?? 'unknown ip'}`)
.error(JSON.stringify(err));
Log.error('Caught new generic error', `Caused by ${req.ip ?? 'unknown ip'}`, JSON.stringify(err));
const error = err as IFullError;

if (error.message.includes('is not valid JSON')) {
Expand Down
1 change: 0 additions & 1 deletion src/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
export * from './logs.js';
7 changes: 0 additions & 7 deletions src/enums/logs.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/errors/handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Log from 'simpl-loggar';
import { InternalError } from './index.js';
import Log from '../tools/logger/index.js';
import type * as types from '../types/index.js';
import type express from 'express';

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Log from 'simpl-loggar';
import Router from './connections/router/index.js';
import Liveness from './tools/liveness.js';
import Log from './tools/logger/index.js';
import State from './tools/state.js';
import type { IFullError } from './types/index.js';

Expand Down
Loading

0 comments on commit fd1d40f

Please sign in to comment.