forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic logging service to wrap output window usage
- Loading branch information
Showing
5 changed files
with
94 additions
and
17,191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": { | ||
"typescript.tsc.autoDetect": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Centralized logging service for the extension. | ||
* Provides a singleton instance for consistent logging across all services. | ||
* | ||
* Usage: | ||
* ```ts | ||
* const logger = LoggerService.getInstance(); | ||
* logger.log("Message", "ServiceName"); | ||
* ``` | ||
*/ | ||
|
||
import * as vscode from "vscode" | ||
|
||
export class LoggerService { | ||
private static instance: LoggerService | ||
private outputChannel: vscode.OutputChannel | ||
private disposed = false | ||
|
||
private constructor() { | ||
this.outputChannel = vscode.window.createOutputChannel("Cline") | ||
} | ||
|
||
public static getInstance(): LoggerService { | ||
if (!LoggerService.instance) { | ||
LoggerService.instance = new LoggerService() | ||
} | ||
return LoggerService.instance | ||
} | ||
|
||
/** | ||
* Log a message with optional source identifier | ||
* @param message The message to log | ||
* @param source Optional source identifier (e.g. service name) | ||
*/ | ||
public log(message: string, source?: string) { | ||
if (this.disposed) return; | ||
const timestamp = new Date().toISOString() | ||
const prefix = source ? `[${source}]` : "" | ||
this.outputChannel.appendLine(`${timestamp} ${prefix} ${message}`) | ||
} | ||
|
||
/** | ||
* Get the underlying VS Code OutputChannel | ||
* For use in extension.ts to register for disposal | ||
*/ | ||
public getOutputChannel(): vscode.OutputChannel { | ||
return this.outputChannel | ||
} | ||
|
||
/** | ||
* Dispose of the output channel | ||
* Should only be called when the extension is deactivated | ||
*/ | ||
public dispose() { | ||
if (!this.disposed) { | ||
this.disposed = true | ||
this.outputChannel.dispose() | ||
} | ||
} | ||
|
||
/** | ||
* Log a service operation with details | ||
* @param service The service name | ||
* @param operation The operation being performed | ||
* @param details Optional additional details | ||
*/ | ||
public logOperation(service: string, operation: string, details?: string) { | ||
const message = details ? `${operation}: ${details}` : operation | ||
this.log(message, service) | ||
} | ||
} |
Oops, something went wrong.