Skip to content

Commit

Permalink
Merge pull request #1150 from dm3-org/removeWinston
Browse files Browse the repository at this point in the history
Remove winston
  • Loading branch information
AlexNi245 authored Sep 2, 2024
2 parents 7a81827 + 9e2191d commit da38428
Show file tree
Hide file tree
Showing 29 changed files with 12 additions and 121 deletions.
1 change: 0 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"prisma": "^5.10.1",
"redis": "^4.1.0",
"web-push": "^3.6.7",
"winston": "^3.8.1",
"yaml": "^2.1.3"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion packages/delivery-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"redis": "^4.1.0",
"socket.io": "^4.5.1",
"web-push": "^3.6.7",
"winston": "^3.8.1",
"yaml": "^2.1.3"
},
"scripts": {
Expand Down
5 changes: 0 additions & 5 deletions packages/delivery-service/src/delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { generateAuthJWT } from '@dm3-org/dm3-lib-server-side';
import bodyParser from 'body-parser';
import express from 'express';
import request from 'supertest';
import winston from 'winston';
import delivery from './delivery';
import { Redis, getDatabase, getRedisClient } from './persistence/getDatabase';

Expand All @@ -22,10 +21,6 @@ const keysA = {

const serverSecret = 'veryImportantSecret';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

let redisClient: Redis;
describe('Delivery', () => {
beforeEach(async () => {
Expand Down
10 changes: 0 additions & 10 deletions packages/delivery-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import express from 'express';
import http from 'http';
import { Server } from 'socket.io';
import webpush from 'web-push';
import winston from 'winston';
import { startCleanUpPendingMessagesJob } from './cleanup/cleanUpPendingMessages';
import { getDeliveryServiceProperties } from './config/getDeliveryServiceProperties';
import Delivery from './delivery';
Expand Down Expand Up @@ -92,15 +91,6 @@ const getDbWithAddressResolvedGetAccount = (
app.use(cors());
app.use(bodyParser.json());

declare global {
var logger: winston.Logger;
}

global.logger = winston.createLogger({
level: process.env.LOG_LEVEL ?? 'info',
transports: [new winston.transports.Console()],
});

(async () => {
// load environment
const deliveryServiceProperties = getDeliveryServiceProperties();
Expand Down
2 changes: 1 addition & 1 deletion packages/delivery-service/src/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function onConnection(
) {
return (socket: Socket) => {
socket.on('disconnect', () => {
global.logger.info({
console.info({
method: 'WS DISCONNECT',
socketId: socket.id,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Redis, IDatabase, getRedisClient, getDatabase } from '../getDatabase';
import winston from 'winston';
import {
DeliveryInformation,
EncryptionEnvelop,
Expand All @@ -8,16 +7,9 @@ import {
const SENDER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';
const RECEIVER_ADDRESS = '0xDd36ae7F9a8E34FACf1e110c6e9d37D0dc917855';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Create Message', () => {
let redisClient: Redis;
let db: IDatabase;
const logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

beforeEach(async () => {
redisClient = await getRedisClient();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import winston from 'winston';
import { getDatabase, getRedisClient, IDatabase, Redis } from '../getDatabase';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Delete Expired messages', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import { EncryptionEnvelop } from '@dm3-org/dm3-lib-messaging';
import winston from 'winston';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';

const SENDER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';
const RECEIVER_ADDRESS = '0xDd36ae7F9a8E34FACf1e110c6e9d37D0dc917855';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Sync Acknowledge', () => {
let redisClient: Redis;
let db: IDatabase;
const logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

beforeEach(async () => {
redisClient = await getRedisClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import {
NotificationChannelType,
} from '@dm3-org/dm3-lib-shared';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import winston from 'winston';

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Set Users NotificationChannel', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import {
NotificationChannel,
} from '@dm3-org/dm3-lib-shared';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import winston from 'winston';

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Enables/Disables users EMAIL notification channel', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import winston from 'winston';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import {
NotificationChannelType,
Expand All @@ -7,10 +6,6 @@ import {

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Removes EMAIL notification channel', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import winston from 'winston';

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Set Users Global Notification', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import winston from 'winston';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import {
NotificationChannelType,
Expand All @@ -7,10 +6,6 @@ import {

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Set users EMAIL notification channel as verified', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { NotificationChannelType } from '@dm3-org/dm3-lib-shared';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import winston from 'winston';

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Reset OTP', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
5 changes: 0 additions & 5 deletions packages/delivery-service/src/persistence/otp/setOtp.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { NotificationChannelType } from '@dm3-org/dm3-lib-shared';
import { IDatabase, Redis, getDatabase, getRedisClient } from '../getDatabase';
import winston from 'winston';

const USER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

describe('Email Verification OTP', () => {
let redisClient: Redis;
let db: IDatabase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export function handleGetDeliveryServiceProperties(
deliveryServiceProperties: DeliveryServiceProperties,
) {
if (!deliveryServiceProperties) {
global.logger.error({
method: 'RPC GET DELIVERY SERVICE PROPERTIES',
error: 'No Delivery Service Properties Set',
});
console.error(
'RPC GET DELIVERY SERVICE PROPERTIES: No Delivery Service Properties Set',
);
return res.status(400).send({
jsonrpc: '2.0',
result: 'No Delivery Service Properties Set',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function handleResolveProfileExtension(axios: Axios, db: IDatabase) {
if (!session) {
//The requested ens-name is not known to the delivery service
const error = 'unknown user';
global.logger.warn({
console.warn({
method: 'RPC - RESOLVE PROFILE',
error,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function handleSubmitMessage(
if (!isSchemaValid) {
const error = 'invalid schema';

global.logger.warn({
console.warn({
method: 'WS SUBMIT MESSAGE',
error,
});
Expand Down
6 changes: 1 addition & 5 deletions packages/delivery-service/src/rpc/rpc-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ import bodyParser from 'body-parser';
import { ethers } from 'ethers';
import express from 'express';
import request from 'supertest';
import winston from 'winston';

import RpcProxy from './rpc-proxy';
import { EncryptionEnvelop } from '@dm3-org/dm3-lib-messaging';

global.logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

const mockWsManager: IWebSocketManager = {
isConnected: function (ensName: string): Promise<boolean> {
return Promise.resolve(false);
Expand Down
5 changes: 1 addition & 4 deletions packages/lib/server-side/src/authorize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import bodyParser from 'body-parser';
import express, { NextFunction, Request, Response } from 'express';
import { sign, verify } from 'jsonwebtoken';
import request from 'supertest';
import winston from 'winston';

import { authorize } from './authorize';

const serverSecret = 'testSecret';
winston.loggers.add('default', {
transports: [new winston.transports.Console({ level: 'silly' })],
});

describe('Utils', () => {
describe('Auth', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/lib/server-side/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import { DeliveryServiceProfileKeys } from '@dm3-org/dm3-lib-profile';
import { ethers } from 'ethers';
import { NextFunction, Request, Response } from 'express';
import winston from 'winston';

export function logRequest(req: Request, res: Response, next: NextFunction) {
winston.loggers.get('default').info({
console.info({
method: req.method,
url: req.url,
timestamp: new Date().getTime(),
Expand Down
1 change: 0 additions & 1 deletion packages/offchain-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"ts-node": "^10.8.1",
"typescript": "^4.4.2",
"uuid": "^9.0.0",
"winston": "^3.8.1",
"yaml": "^2.1.3"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/offchain-resolver/src/http/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ethers } from 'ethers';
import express from 'express';

import request from 'supertest';
import winston from 'winston';

import { getDatabase, getDbClient } from '../persistence/getDatabase';
import { IDatabase } from '../persistence/IDatabase';
import { profile } from './profile';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignedUserProfile } from '@dm3-org/dm3-lib-profile';
import { ethers } from 'ethers';
import winston from 'winston';

import { getProfileContainer, setUserProfile } from '.';
import { IDatabase } from '../IDatabase';
import { getDatabase, getDbClient } from '../getDatabase';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import winston from 'winston';
import { getDatabase, getDbClient } from '../getDatabase';
import { IDatabase } from '../IDatabase';
const SENDER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import winston from 'winston';
import { getDatabase, getDbClient } from '../getDatabase';
import { IDatabase } from '../IDatabase';
const SENDER_ADDRESS = '0x25A643B6e52864d0eD816F1E43c0CF49C83B8292';
Expand Down
2 changes: 0 additions & 2 deletions packages/offchain-resolver/src/persistence/profile/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import winston from 'winston';

export { getProfileContainer } from './getProfileContainer';
export { getProfileContainerByAddress } from './getProfileContainerByAddress';
export { removeUserProfile } from './removeUserProfile';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IDatabase } from '../IDatabase';
import { setUserProfile } from './setUserProfile';
import { removeUserProfile } from './removeUserProfile';
import { ethers } from 'ethers';
import winston from 'winston';

import { SignedUserProfile } from '@dm3-org/dm3-lib-profile';
import { PrismaClient } from '@prisma/client';
import { clearDb } from '../clearDb';
Expand Down
Loading

0 comments on commit da38428

Please sign in to comment.