Skip to content

Commit 6a69956

Browse files
committed
Add owner name to logs and notifications
1 parent af8a2b3 commit 6a69956

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/workspaceMonitor.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ export class WorkspaceMonitor implements vscode.Disposable {
2727
readonly onChange = new vscode.EventEmitter<Workspace>()
2828
private readonly updateStatusBarItem: vscode.StatusBarItem
2929

30+
// For logging.
31+
private readonly name: String
32+
3033
constructor(
3134
workspace: Workspace,
3235
private readonly restClient: Api,
3336
private readonly storage: Storage,
3437
) {
38+
this.name = `${workspace.owner_name}/${workspace.name}`
3539
const url = this.restClient.getAxiosInstance().defaults.baseURL
3640
const token = this.restClient.getAxiosInstance().defaults.headers.common["Coder-Session-Token"] as
3741
| string
3842
| undefined
3943
const watchUrl = new URL(`${url}/api/v2/workspaces/${workspace.id}/watch`)
40-
this.storage.writeToCoderOutputChannel(`Monitoring ${watchUrl}`)
44+
this.storage.writeToCoderOutputChannel(`Monitoring ${this.name}...`)
4145

4246
const eventSource = new EventSource(watchUrl.toString(), {
4347
headers: {
@@ -77,6 +81,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
7781
*/
7882
dispose() {
7983
if (!this.disposed) {
84+
this.storage.writeToCoderOutputChannel(`Unmonitoring ${this.name}...`)
8085
this.updateStatusBarItem.dispose()
8186
this.eventSource.close()
8287
this.disposed = true
@@ -103,7 +108,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
103108
this.isImpending(workspace.latest_build.deadline, this.autostopNotifyTime)
104109
) {
105110
const toAutostopTime = formatDistanceToNowStrict(new Date(workspace.latest_build.deadline))
106-
vscode.window.showInformationMessage(`${workspace.name} is scheduled to shut down in ${toAutostopTime}.`)
111+
vscode.window.showInformationMessage(`${this.name} is scheduled to shut down in ${toAutostopTime}.`)
107112
this.notifiedAutostop = true
108113
}
109114
}
@@ -115,7 +120,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
115120
this.isImpending(workspace.deleting_at, this.deletionNotifyTime)
116121
) {
117122
const toShutdownTime = formatDistanceToNowStrict(new Date(workspace.deleting_at))
118-
vscode.window.showInformationMessage(`${workspace.name} is scheduled for deletion in ${toShutdownTime}.`)
123+
vscode.window.showInformationMessage(`${this.name} is scheduled for deletion in ${toShutdownTime}.`)
119124
this.notifiedDeletion = true
120125
}
121126
}

0 commit comments

Comments
 (0)