Skip to content

Commit

Permalink
fix(device): add init log and change logger context name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozwiaczek committed Aug 1, 2021
1 parent a405086 commit 65afa0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/device/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = {
'@typescript-eslint/no-unsafe-call': 0,
'security/detect-non-literal-fs-filename': 0,
'@typescript-eslint/no-explicit-any': 0,
'testing-library/no-debug': 0,
},
};
8 changes: 5 additions & 3 deletions packages/device/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Logger } from './utils';

dotenv.config();
actionExecutor((actionsConfig as ActionConfig).onInit);
const logger = new Logger('EventsFactory');
const logger = new Logger('SocketConnection');

const socket = socketClient(process.env.API_URL ?? '', {
query: {
Expand All @@ -19,6 +19,8 @@ const socket = socketClient(process.env.API_URL ?? '', {
reconnectionDelay: 1000,
});

logger.log('Initialized');

enum WebSocketEvent {
CHECK_DEVICE_CONNECTION = 'checkDeviceConnection',
TOGGLE_GATE = 'toggleGate',
Expand All @@ -39,9 +41,9 @@ socket.on('message', (eventType: WebSocketEvent) => {
});

socket.on('connect', () => {
logger.log(`Connected with API`);
logger.log(`Connected`);
});

socket.on('disconnect', () => {
logger.log(`Disconnect with API`);
logger.log(`Disconnect`);
});

0 comments on commit 65afa0f

Please sign in to comment.