diff --git a/package.json b/package.json index e550941..2cb38ab 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "start": "ts-node-dev --respawn --transpile-only src/client.ts", + "local": "ts-node-dev --respawn --transpile-only src/client.ts start -p local", "build": "tsc" }, "repository": { diff --git a/src/client.ts b/src/client.ts index 3d76e60..009f1c4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -98,7 +98,7 @@ function initClient(options: any) { }); socket.on("connect_error", (e) => { - console.log( + console.error( `${clientLogPrefix} connect error:`, (e && e.message) || "something wrong" ); @@ -108,11 +108,11 @@ function initClient(options: any) { }); socket.on("disconnect", (reason) => { - console.log(`${clientLogPrefix} disconnected: ${reason}!`); + console.warn(`${clientLogPrefix} disconnected: ${reason}!`); }); socket.on("disconnect_exit", (reason) => { - console.log(`${clientLogPrefix} disconnected and exited ${reason}!`); + console.warn(`${clientLogPrefix} disconnected and exited ${reason}!`); socket?.disconnect(); process.exit(1); }); @@ -133,6 +133,7 @@ function initClient(options: any) { tunnelRequest.pipe(localReq); const onTunnelRequestError = (e: any) => { + console.error("tunnel request error: ", e); tunnelRequest.off("end", onTunnelRequestEnd); localReq.destroy(e); }; @@ -164,7 +165,7 @@ function initClient(options: any) { }; const onLocalError = (error: any) => { - console.log(error); + console.error("local error:", error); localReq.off("response", onLocalResponse); socket?.emit("request-error", requestId, error && error.message); tunnelRequest.destroy(error);