Skip to content

Commit

Permalink
feat: simplify LogWriter interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Nov 6, 2021
1 parent 0f76d74 commit 935c12a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/factories/createNodeWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import type {
} from '../types';

const createBlockingWriter = (stream: NodeJS.WritableStream): LogWriter => {
return {
write: (message: string) => {
stream.write(message + '\n');
},
return (message: string) => {
stream.write(message + '\n');
};
};

Expand Down
4 changes: 3 additions & 1 deletion src/factories/createRoarrInitialGlobalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export const createRoarrInitialGlobalState = (currentState: any): RoarrGlobalSta

newState = {
...newState,
...createNodeWriter(),
...{
write: createNodeWriter(),
},
asyncLocalStorage,
};
// eslint-disable-next-line no-empty
Expand Down
7 changes: 3 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import type {
AsyncLocalStorage,
} from 'async_hooks';

export type LogWriter = {
write: (message: string) => void,
};
export type LogWriter = (message: string) => void;

export type MessageContext = any;

export type RoarrGlobalState = LogWriter & {
export type RoarrGlobalState = {
asyncLocalStorage?: AsyncLocalStorage<MessageContext>,
sequence: number,
versions: readonly string[],
write: LogWriter,
};

export type SprintfArgument = boolean | number | string | null;
Expand Down

0 comments on commit 935c12a

Please sign in to comment.