cleaning logger types

This commit is contained in:
tiagosiebler
2021-02-07 16:53:32 +00:00
parent eb5f8333c1
commit 4ee7de3774
3 changed files with 6 additions and 8 deletions

View File

@@ -1,7 +1,5 @@
export type LogParams = null | any; export type LogParams = null | any;
export type Logger = typeof DefaultLogger;
export const DefaultLogger = { export const DefaultLogger = {
silly: (...params: LogParams): void => { silly: (...params: LogParams): void => {
console.log(params); console.log(params);

View File

@@ -1,5 +1,5 @@
import { WsConnectionState } from '../websocket-client'; import { WsConnectionState } from '../websocket-client';
import { DefaultLogger, Logger } from '../logger'; import { DefaultLogger } from '../logger';
import WebSocket from 'isomorphic-ws'; import WebSocket from 'isomorphic-ws';
@@ -20,9 +20,9 @@ export default class WsStore {
private wsState: { private wsState: {
[key: string]: WsStoredState; [key: string]: WsStoredState;
} }
private logger: Logger; private logger: typeof DefaultLogger;
constructor(logger: Logger) { constructor(logger: typeof DefaultLogger) {
this.logger = logger || DefaultLogger; this.logger = logger || DefaultLogger;
this.wsState = {}; this.wsState = {};
} }

View File

@@ -1,7 +1,7 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { InverseClient } from './inverse-client'; import { InverseClient } from './inverse-client';
import { LinearClient } from './linear-client'; import { LinearClient } from './linear-client';
import { DefaultLogger, Logger } from './logger'; import { DefaultLogger } from './logger';
import { signMessage, serializeParams, isWsPong } from './util/requestUtils'; import { signMessage, serializeParams, isWsPong } from './util/requestUtils';
import WebSocket from 'isomorphic-ws'; import WebSocket from 'isomorphic-ws';
@@ -76,12 +76,12 @@ const getLinearWsKeyForTopic = (topic: string) => {
} }
export class WebsocketClient extends EventEmitter { export class WebsocketClient extends EventEmitter {
private logger: Logger; private logger: typeof DefaultLogger;
private restClient: InverseClient | LinearClient; private restClient: InverseClient | LinearClient;
private options: WebsocketClientOptions; private options: WebsocketClientOptions;
private wsStore: WsStore; private wsStore: WsStore;
constructor(options: WSClientConfigurableOptions, logger?: Logger) { constructor(options: WSClientConfigurableOptions, logger?: typeof DefaultLogger) {
super(); super();
this.logger = logger || DefaultLogger; this.logger = logger || DefaultLogger;