-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from mikkelhegn/main
Always install latest version - and also some strcutured logging
- Loading branch information
Showing
8 changed files
with
989 additions
and
519 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,66 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
const OUTPUT_CHANNEL = vscode.window.createOutputChannel("Spin", ); | ||
|
||
let shownInstallErrorToast = false; | ||
|
||
enum logLevel { | ||
Info = "Info", | ||
Warning = "Warning", | ||
Error = "Error", | ||
} | ||
|
||
interface logMessage { | ||
level: logLevel, | ||
function: string, | ||
message: string, | ||
} | ||
|
||
export function info(caller: string, message: string) { | ||
const log: logMessage = { | ||
level:logLevel.Info, | ||
function: caller, | ||
message: message | ||
}; | ||
OUTPUT_CHANNEL.appendLine(formatLog(log)); | ||
} | ||
|
||
export function warning(caller: string, message: string) { | ||
const log: logMessage = { | ||
level:logLevel.Warning, | ||
function: caller, | ||
message: message | ||
}; | ||
OUTPUT_CHANNEL.appendLine(formatLog(log)); | ||
} | ||
|
||
export function error(caller: string, message: string) { | ||
const log: logMessage = { | ||
level:logLevel.Error, | ||
function: caller, | ||
message: message | ||
}; | ||
OUTPUT_CHANNEL.appendLine(formatLog(log)); | ||
} | ||
|
||
export function logMessage(logMessage: logMessage) { | ||
OUTPUT_CHANNEL.appendLine(formatLog(logMessage)); | ||
} | ||
|
||
export function warnInstallNotEnsured(message: string, always?: 'always' | 'if-not-shown') { | ||
if (!shownInstallErrorToast || always === 'always') { | ||
shownInstallErrorToast = true; | ||
vscode.window.showWarningMessage(message); | ||
} else { | ||
warning(warnInstallNotEnsured.name, message); | ||
} | ||
} | ||
|
||
export function show(preserveFocus?: boolean) { | ||
OUTPUT_CHANNEL.show(preserveFocus); | ||
} | ||
|
||
function formatLog(log: logMessage): string { | ||
const date = new Date().toISOString(); | ||
return `${date} [${log.level}] ${log.message}`; | ||
} |
This file was deleted.
Oops, something went wrong.
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