Skip to content

Commit a343efe

Browse files
committed
Fix logging link errors
Unfortunately the logger currently chokes when provided with error objects. Also for some reason the bracketed text was not displaying...
1 parent 070d131 commit a343efe

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/common/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const arrayify = <T>(value?: T | T[]): T[] => {
6565
}
6666

6767
// TODO: Might make sense to add Error handling to the logger itself.
68-
export function logError(logger: { error: (msg: string) => void }, prefix: string, err: Error | string): void {
68+
export function logError(logger: { error: (msg: string) => void }, prefix: string, err: unknown): void {
6969
if (err instanceof Error) {
7070
logger.error(`${prefix}: ${err.message} ${err.stack}`)
7171
} else {

src/node/main.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChildProcessWithoutNullStreams } from "child_process"
33
import http from "http"
44
import path from "path"
55
import { Disposable } from "../common/emitter"
6-
import { plural } from "../common/util"
6+
import { plural, logError } from "../common/util"
77
import { createApp, ensureAddress } from "./app"
88
import { AuthType, DefaultedArgs, Feature } from "./cli"
99
import { coderCloudBind } from "./coder_cloud"
@@ -160,13 +160,13 @@ export const runCodeServer = async (
160160
try {
161161
linkAgent = startLink(serverAddress)
162162
linkAgent.on("error", (error) => {
163-
logger.debug("[Link daemon]", field("error", error))
163+
logError(logger, "link daemon", error)
164164
})
165165
linkAgent.on("close", (code) => {
166-
logger.debug("[Link daemon]", field("code", `Closed with code ${code}`))
166+
logger.debug("link daemon closed", field("code", code))
167167
})
168168
} catch (error) {
169-
logger.debug("Failed to start link daemon!", error as any)
169+
logError(logger, "link daemon", error)
170170
}
171171

172172
if (args.enable && args.enable.length > 0) {

0 commit comments

Comments
 (0)