diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-23 10:02:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-23 10:02:08 +0000 |
commit | 58d44c6ba2de32a31a09bbcaf61365a69b69374c (patch) | |
tree | 40f50d70e9ac2bb48d680e4b2fc4a4480eaf4f99 /editors/code/src/installation/server.ts | |
parent | dea1d957e5fec51e8210b3fc4d2db7099d0ff000 (diff) | |
parent | 49844ab717d8d1790dbdf7f44d160936ece0e80f (diff) |
Merge #3261
3261: Extract client-side logging r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/installation/server.ts')
-rw-r--r-- | editors/code/src/installation/server.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts index 750852921..685abfdc6 100644 --- a/editors/code/src/installation/server.ts +++ b/editors/code/src/installation/server.ts | |||
@@ -7,6 +7,7 @@ import { spawnSync } from "child_process"; | |||
7 | import { BinarySource } from "./interfaces"; | 7 | import { BinarySource } from "./interfaces"; |
8 | import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; | 8 | import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; |
9 | import { downloadArtifact } from "./download_artifact"; | 9 | import { downloadArtifact } from "./download_artifact"; |
10 | import { log } from "../util"; | ||
10 | 11 | ||
11 | export async function ensureServerBinary(source: null | BinarySource): Promise<null | string> { | 12 | export async function ensureServerBinary(source: null | BinarySource): Promise<null | string> { |
12 | if (!source) { | 13 | if (!source) { |
@@ -40,7 +41,7 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n | |||
40 | const installedVersion: null | string = getServerVersion(source.storage); | 41 | const installedVersion: null | string = getServerVersion(source.storage); |
41 | const requiredVersion: string = source.version; | 42 | const requiredVersion: string = source.version; |
42 | 43 | ||
43 | console.log("Installed version:", installedVersion, "required:", requiredVersion); | 44 | log.debug("Installed version:", installedVersion, "required:", requiredVersion); |
44 | 45 | ||
45 | if (isBinaryAvailable(prebuiltBinaryPath) && installedVersion === requiredVersion) { | 46 | if (isBinaryAvailable(prebuiltBinaryPath) && installedVersion === requiredVersion) { |
46 | return prebuiltBinaryPath; | 47 | return prebuiltBinaryPath; |
@@ -72,16 +73,16 @@ async function downloadServer(source: BinarySource.GithubRelease): Promise<boole | |||
72 | `GitHub repository: ${err.message}` | 73 | `GitHub repository: ${err.message}` |
73 | ); | 74 | ); |
74 | 75 | ||
75 | console.error(err); | 76 | log.error(err); |
76 | 77 | ||
77 | dns.resolve('example.com').then( | 78 | dns.resolve('example.com').then( |
78 | addrs => console.log("DNS resolution for example.com was successful", addrs), | 79 | addrs => log.debug("DNS resolution for example.com was successful", addrs), |
79 | err => { | 80 | err => { |
80 | console.error( | 81 | log.error( |
81 | "DNS resolution for example.com failed, " + | 82 | "DNS resolution for example.com failed, " + |
82 | "there might be an issue with Internet availability" | 83 | "there might be an issue with Internet availability" |
83 | ); | 84 | ); |
84 | console.error(err); | 85 | log.error(err); |
85 | } | 86 | } |
86 | ); | 87 | ); |
87 | return false; | 88 | return false; |
@@ -105,19 +106,19 @@ function isBinaryAvailable(binaryPath: string): boolean { | |||
105 | // ACHTUNG! `res` type declaration is inherently wrong, see | 106 | // ACHTUNG! `res` type declaration is inherently wrong, see |
106 | // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42221 | 107 | // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/42221 |
107 | 108 | ||
108 | console.log("Checked binary availablity via --version", res); | 109 | log.debug("Checked binary availablity via --version", res); |
109 | console.log(binaryPath, "--version output:", res.output?.map(String)); | 110 | log.debug(binaryPath, "--version output:", res.output?.map(String)); |
110 | 111 | ||
111 | return res.status === 0; | 112 | return res.status === 0; |
112 | } | 113 | } |
113 | 114 | ||
114 | function getServerVersion(storage: vscode.Memento): null | string { | 115 | function getServerVersion(storage: vscode.Memento): null | string { |
115 | const version = storage.get<null | string>("server-version", null); | 116 | const version = storage.get<null | string>("server-version", null); |
116 | console.log("Get server-version:", version); | 117 | log.debug("Get server-version:", version); |
117 | return version; | 118 | return version; |
118 | } | 119 | } |
119 | 120 | ||
120 | async function setServerVersion(storage: vscode.Memento, version: string): Promise<void> { | 121 | async function setServerVersion(storage: vscode.Memento, version: string): Promise<void> { |
121 | console.log("Set server-version:", version); | 122 | log.debug("Set server-version:", version); |
122 | await storage.update("server-version", version.toString()); | 123 | await storage.update("server-version", version.toString()); |
123 | } | 124 | } |