Skip to content

Commit 0e76965

Browse files
authored
chore: do not extend writable, use destinationstream from pino (#167)
* chore: do not extend writable, use destinationstream from pino * chore: bump patch version
1 parent a7249be commit 0e76965

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

misc/logger/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @walletconnect/logger
22

3+
## 2.1.2
4+
5+
### Patch Changes
6+
7+
- Fix build bug caused by depending on stream
8+
39
## 2.1.1
410

511
### Patch Changes

misc/logger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@walletconnect/logger",
33
"description": "Logger Utils",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"author": "WalletConnect, Inc. <walletconnect.com>",
66
"license": "MIT",
77
"homepage": "https://github.com/WalletConnect/walletconnect-utils/",

misc/logger/src/serverChunkLogger.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
import { MAX_LOG_SIZE_IN_BYTES_DEFAULT } from "./constants";
2-
import { Writable } from "stream";
3-
import type { LoggerOptions } from "pino";
2+
import type { DestinationStream, LoggerOptions } from "pino";
43
import BaseChunkLogger from "./baseChunkLogger";
54

6-
export default class ServerChunkLogger extends Writable {
5+
export default class ServerChunkLogger implements DestinationStream {
76
private baseChunkLogger: BaseChunkLogger;
87

98
public constructor(
109
level: LoggerOptions["level"],
1110
MAX_LOG_SIZE_IN_BYTES: number = MAX_LOG_SIZE_IN_BYTES_DEFAULT,
1211
) {
13-
super({ objectMode: true });
14-
1512
this.baseChunkLogger = new BaseChunkLogger(level, MAX_LOG_SIZE_IN_BYTES);
1613
}
1714

18-
public _write(chunk: any, _encoding: string, callback: (error?: Error | null) => void): void {
19-
try {
20-
this.baseChunkLogger.appendToLogs(chunk);
21-
callback();
22-
} catch (error: any) {
23-
callback(error);
24-
}
15+
public write(chunk: any): void {
16+
this.baseChunkLogger.appendToLogs(chunk);
2517
}
2618

2719
public getLogs() {

0 commit comments

Comments
 (0)