From 7fabe8e61dcfbb329fad89ebd619a9171e4e4e8a Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 7 Dec 2022 04:27:19 -0500 Subject: [PATCH] *use logger --- src/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index df6a1f4..4d499eb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,9 +6,11 @@ import SPVNode from "hsd/lib/node/spvnode.js"; // @ts-ignore import { NodeClient } from "hs-client"; -async function boot(config: any) { +async function boot(api: PluginAPI) { let hsdServer: SPVNode; + const { config } = api; + let clientArgs = { network: "main", host: "127.0.0.1", @@ -33,20 +35,20 @@ async function boot(config: any) { }); hsdServer.on("abort", async (err: any) => { const timeout = setTimeout(() => { - console.error("Shutdown is taking a long time. Exiting."); + api.logger.error("Shutdown is taking a long time. Exiting."); process.exit(3); }, 5000); timeout.unref(); try { - console.error("Shutting down..."); + api.logger.error("Shutting down..."); await hsdServer.close(); clearTimeout(timeout); - console.error((err as Error).stack); + api.logger.error((err as Error).stack); process.exit(2); } catch (e: any) { - console.error( + api.logger.error( `Error occurred during shutdown: ${(e as Error).message}` ); process.exit(3); @@ -61,7 +63,7 @@ async function boot(config: any) { hsdServer.startSync(); } catch (e: any) { - console.error((e as Error).stack); + api.logger.error((e as Error).stack); } })(); } else { @@ -79,7 +81,7 @@ async function boot(config: any) { const plugin: Plugin = { name: "handshake", async plugin(api: PluginAPI): Promise { - const client = await boot(api.config); + const client = await boot(api); api.registerMethod("getnameresource", { cacheable: true,