Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import type { CredentialStore } from './managers/CredentialStore';
import type { DevicesViewProvider } from './viewProviders/DevicesViewProvider';
import { DEVICE_FILTER_KEYS } from './deviceFilters';
import { rokuDeploy } from 'roku-deploy';
import { createLogger } from './logging';

const logger = createLogger('BrightScriptCommands');

export class BrightScriptCommands {

Expand Down Expand Up @@ -82,7 +85,7 @@ export class BrightScriptCommands {
placeholder: 'Press enter to send all typed characters to the Roku',
items: items
});
console.log('userInput', stuffUserTyped);
logger.log('userInput', stuffUserTyped);

if (stuffUserTyped) {
new GlobalStateManager(this.context).addTextHistory(stuffUserTyped);
Expand All @@ -96,7 +99,7 @@ export class BrightScriptCommands {
// fallbackToHttp = false;
// }
// } catch (error) {
// console.error(error);
// logger.error(error);
// // Let this fallback to the old HTTP based logic
// }

Expand Down Expand Up @@ -908,7 +911,7 @@ export class BrightScriptCommands {

if (host) {
let clickUrl = `http://${host}:8060/keypress/${key}`;
console.log(`send ${clickUrl}`);
logger.log(`send ${clickUrl}`);
return new Promise((resolve, reject) => {
request.post(clickUrl, (err, response) => {
if (err) {
Expand Down Expand Up @@ -940,7 +943,7 @@ export class BrightScriptCommands {
try {
this.host = await rokuDebugUtil.dnsLookup(this.host);
} catch (e) {
console.error('Error doing dns lookup for host ', this.host, e);
logger.error('Error doing dns lookup for host ', this.host, e);
}
}
return this.host;
Expand Down
5 changes: 4 additions & 1 deletion src/BrightScriptDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
SymbolKind
} from 'vscode';
import * as vscode from 'vscode';
import { createLogger } from './logging';

const logger = createLogger('BrightScriptDeclaration');

export class BrightScriptDeclaration {
constructor(
Expand Down Expand Up @@ -42,7 +45,7 @@ export class BrightScriptDeclaration {
} else if (this.container) {
return this.container.getDocumentUri();
} else {
console.log('getDocumentUri: ERROR could not find container for symbol' + this);
logger.log('getDocumentUri: ERROR could not find container for symbol' + this);
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import type { BrightScriptCommands } from './BrightScriptCommands';
import type { RokuProjectManager } from './managers/RokuProject/RokuProjectManager';
import type { DeviceManager, RokuDevice } from './deviceDiscovery/DeviceManager';
import type { CredentialStore } from './managers/CredentialStore';
import { createLogger } from './logging';

const logger = createLogger('DebugConfigurationProvider');


export class BrightScriptDebugConfigurationProvider implements DebugConfigurationProvider {
Expand Down Expand Up @@ -370,7 +373,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
}

if (!config.rootDir) {
console.log('No rootDir specified: defaulting to ${workspaceFolder}');
logger.log('No rootDir specified: defaulting to ${workspaceFolder}');
//use the current workspace folder
config.rootDir = folderUri.fsPath;
}
Expand Down Expand Up @@ -434,7 +437,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
}
if (await this.util.fileExists(envFilePath) === false) {
//the .env file is optional, so just warn instead of failing the debug session
console.warn(`Cannot find .env file at "${envFilePath}". Falling back to the process environment for '\${env:*}' values.`);
logger.warn(`Cannot find .env file at "${envFilePath}". Falling back to the process environment for '\${env:*}' values.`);
} else {
//parse the .env file, letting its values override the process environment
environmentValues = {
Expand Down Expand Up @@ -476,7 +479,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
while ((match = regexp.exec(configValue))) {
let environmentVariableName = match[1];
configValue = configDefaults[key];
console.log(`The configuration value for ${key} was not found in the environment variables${loadedEnvFile ? ' or env file' : ''} under the name ${environmentVariableName}. Defaulting the value to: ${configValue}`);
logger.log(`The configuration value for ${key} was not found in the environment variables${loadedEnvFile ? ' or env file' : ''} under the name ${environmentVariableName}. Defaulting the value to: ${configValue}`);
}
config[key] = configValue;
}
Expand Down Expand Up @@ -696,7 +699,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
} catch (e) {
//only log the error if the user explicitly defined a config path
if (!isDefaultPath) {
console.error(`Could not load bsconfig file at "${configFilePath}`);
logger.error(`Could not load bsconfig file at "${configFilePath}`);
}
return undefined;
}
Expand Down
23 changes: 13 additions & 10 deletions src/DeclarationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {

import { BrightScriptDeclaration } from './BrightScriptDeclaration';
import { util } from './util';
import { createLogger } from './logging';

const logger = createLogger('DeclarationProvider');

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// CREDIT WHERE CREDIT IS DUE
Expand Down Expand Up @@ -273,13 +276,13 @@ export class DeclarationProvider implements Disposable {
};

for (const [line, text] of iterlines(input)) {
// console.log("" + line + ": " + text);
// logger.log("" + line + ": " + text);
funcEndLine = line;
funcEndChar = text.length;

//FUNCTION START
let match = /^\s*(?:public|protected|private)*\s*(?:override)*\s*(?:function|sub)\s+(.*[^\(])\s*\((.*)\)/i.exec(text);
// console.log("match " + match);
// logger.log("match " + match);
if (match !== null) {
// function has started
if (currentFunction !== undefined) {
Expand All @@ -300,7 +303,7 @@ export class DeclarationProvider implements Disposable {
//FUNCTION END
match = /^\s*(end)\s*(function|sub)/i.exec(text);
if (match !== null) {
// console.log("function END");
// logger.log("function END");
if (currentFunction !== undefined) {
currentFunction.bodyRange = currentFunction.bodyRange.with({ end: new Position(funcEndLine, funcEndChar) });
//reset so the function's range isn't stretched over whatever follows it (e.g. a nested namespace)
Expand All @@ -312,7 +315,7 @@ export class DeclarationProvider implements Disposable {
// //FIELD
match = /^(?!.*\()(?: |\t)*(public|private|protected)(?: |\t)*([a-z|\.|_]*).*((?: |\t)*=(?: |\t)*.*)*$/i.exec(text);
if (match !== null) {
// console.log("FOUND VAR " + match);
// logger.log("FOUND VAR " + match);
const name = match[2].trim();
if (mDefs[name] !== true) {
mDefs[name] = true;
Expand All @@ -324,7 +327,7 @@ export class DeclarationProvider implements Disposable {
new Range(line, match[0].length - match[1].length, line, match[0].length),
new Range(line, 0, line, text.length)
);
// console.log('FOUND VAR ' + varSymbol.name);
// logger.log('FOUND VAR ' + varSymbol.name);
symbols.push(varSymbol);
}
continue;
Expand All @@ -346,7 +349,7 @@ export class DeclarationProvider implements Disposable {
new Range(line, match[0].length - match[1].length, line, match[0].length),
new Range(line, 0, line, text.length)
);
// console.log('FOUND NAMESPACES ' + namespaceSymbol.name);
// logger.log('FOUND NAMESPACES ' + namespaceSymbol.name);
symbols.push(namespaceSymbol);
namespaces.add(name.toLowerCase());
containerStack.push(namespaceSymbol);
Expand All @@ -373,7 +376,7 @@ export class DeclarationProvider implements Disposable {
new Range(line, match[0].length - match[1].length, line, match[0].length),
new Range(line, 0, line, text.length)
);
// console.log('FOUND enumS ' + enumSymbol.name);
// logger.log('FOUND enumS ' + enumSymbol.name);
symbols.push(enumSymbol);
enums.add(name.toLowerCase());
containerStack.push(enumSymbol);
Expand All @@ -400,7 +403,7 @@ export class DeclarationProvider implements Disposable {
new Range(line, match[0].length - match[2].length, line, match[0].length),
new Range(line, 0, line, text.length)
);
// console.log('FOUND CLASS ' + classSymbol.name);
// logger.log('FOUND CLASS ' + classSymbol.name);
symbols.push(classSymbol);
classes.add(name.toLowerCase());
containerStack.push(classSymbol);
Expand All @@ -427,7 +430,7 @@ export class DeclarationProvider implements Disposable {
new Range(line, match[0].length - match[2].length, line, match[0].length),
new Range(line, 0, line, text.length)
);
// console.log('FOUND interface ' + interfaceSymbol.name);
// logger.log('FOUND interface ' + interfaceSymbol.name);
symbols.push(interfaceSymbol);
interfaces.add(name.toLowerCase());
containerStack.push(interfaceSymbol);
Expand Down Expand Up @@ -468,7 +471,7 @@ export class DeclarationProvider implements Disposable {
// if there was no match, then get the declarations now
symbols = this.cache.get(filePath);
} catch (e) {
console.error(`error loading symbols for file ${filePath}: ${e.message}`);
logger.error(`error loading symbols for file ${filePath}: ${e.message}`);
}
}
//try to load it now
Expand Down
5 changes: 4 additions & 1 deletion src/DefinitionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import type {
import { BrightScriptDeclaration } from './BrightScriptDeclaration';
import type { DeclarationProvider } from './DeclarationProvider';
import { getExcludeGlob } from './DeclarationProvider';
import { createLogger } from './logging';

const logger = createLogger('DefinitionRepository');

export class DefinitionRepository {

Expand Down Expand Up @@ -126,7 +129,7 @@ export class DefinitionRepository {
}
const fresh = new Set<string>([document.uri.fsPath]);
for (const doc of vscode.workspace.textDocuments) {
console.log('>>>>>doc ' + doc.uri.path);
logger.log('>>>>>doc ' + doc.uri.path);

if (!doc.isDirty) {
continue;
Expand Down
13 changes: 7 additions & 6 deletions src/LanguageServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as path from 'path';
import type { Disposable } from 'vscode';
import { window, workspace } from 'vscode';
import { BusyStatus, NotificationName, standardizePath as s } from 'brighterscript';
import { Logger } from '@rokucommunity/logger';
import { CustomCommands, Deferred } from 'brighterscript';
import { createLogger } from './logging';
import type { CodeWithSourceMap } from 'source-map';
import BrightScriptDefinitionProvider from './BrightScriptDefinitionProvider';
import { BrightScriptWorkspaceSymbolProvider, SymbolInformationRepository } from './SymbolInformationRepository';
Expand All @@ -22,6 +22,8 @@ import * as dayjs from 'dayjs';
import type { LocalPackageManager, ParsedVersionInfo } from './managers/LocalPackageManager';
import { firstBy } from 'thenby';

const logger = createLogger('LanguageServerManager');

/**
* Tracks the running/stopped state of the language server. When the lsp crashes, vscode will restart it. After the 5th crash, they'll leave it permanently crashed.
* There seems to be no time limit on adding up to the 5, so even after a few days, vscode may still terminate the language server.
Expand Down Expand Up @@ -279,7 +281,7 @@ export class LanguageServerManager {
this.client = this.constructLanguageClient();

this.client.onDidChangeState((event: StateChangeEvent) => {
console.log(new Date().toLocaleTimeString(), 'onDidChangeState', State[event.newState]);
logger.log('onDidChangeState', State[event.newState]);
this.lspRunTracker.setState(event.newState);
});

Expand Down Expand Up @@ -316,7 +318,6 @@ export class LanguageServerManager {
private registerBusyStatusHandler() {
let timeoutHandle: NodeJS.Timeout;

const logger = new Logger();
this.client.onNotification(NotificationName.busyStatus, (event: any) => {
this.updateStatusbar(event.status === BusyStatus.busy, event.activeRuns);

Expand Down Expand Up @@ -487,7 +488,7 @@ export class LanguageServerManager {
try {
this.selectedBscInfo = await this.ensureBscVersionInstalled(versionInfo);
} catch (e) {
console.error(e);
logger.error(e);
//fall back to the embedded version, and show a popup (don't await the popup because that blocks this flow)
void vscode.window.showErrorMessage(`Language server failure. Did you forget \`npm install\`? Using embedded version ${this.embeddedBscInfo.version}. Can't find language server for "${versionInfo}"`);
this.selectedBscInfo = this.embeddedBscInfo;
Expand Down Expand Up @@ -608,7 +609,7 @@ export class LanguageServerManager {

} catch (e) {
if (retryCount > 0) {
console.error('Failed to install brighterscript', versionInfo, e);
logger.error('Failed to install brighterscript', versionInfo, e);

//if the install failed for some reason, uninstall the package and try again
await this.localPackageManager.uninstall('brighterscript', versionInfo);
Expand Down Expand Up @@ -673,7 +674,7 @@ function OneAtATime(options: { timeout?: number }) {
//race for the timeout to expire (we give up waiting for the previous task to complete)
timer.then(() => {
//our timer fired before we had a chance to cancel it. Report the error and move on
console.error(`timer expired waiting for the previous ${propertyKey} to complete. Running the next instance`, target);
logger.error(`timer expired waiting for the previous ${propertyKey} to complete. Running the next instance`, target);
})
//now we can move on to the actual task
]).then(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/LogDocumentLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { DocumentLink, Position, Range } from 'vscode';
import * as vscode from 'vscode';
import BrightscriptFileUtils from './BrightScriptFileUtils';
import type { BrightScriptLaunchConfiguration } from './DebugConfigurationProvider';
import { createLogger } from './logging';

const logger = createLogger('LogDocumentLinkProvider');

export class CustomDocumentLink {
constructor(outputLine: number, startChar: number, length: number, pkgPath: string, lineNumber: number, filename: string) {
Expand Down Expand Up @@ -89,7 +92,7 @@ export class LogDocumentLinkProvider implements vscode.DocumentLinkProvider {
let uri = vscode.Uri.parse(`vscode://rokucommunity.brightscript/openFile/${customLink.pkgPath}#${customLink.lineNumber}`);
this.customLinks.push(new DocumentLink(range, uri));
} else {
console.log('could not find matching file for link with path ' + customLink.pkgPath);
logger.log('could not find matching file for link with path ' + customLink.pkgPath);
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/LogOutputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { util } from './util';
import * as fsExtra from 'fs-extra';
import type { BrightScriptLaunchConfiguration } from './DebugConfigurationProvider';
import stripAnsi from 'strip-ansi';
import { createLogger } from './logging';

const logger = createLogger('LogOutputManager');

export class LogLine {
constructor(
Expand Down Expand Up @@ -259,12 +262,12 @@ export class LogOutputManager {
if (!this.includeStackTraces) {
// filter out debugger noise
if (this.debugStartRegex.exec(line)) {
console.log('start MicroDebugger block');
logger.log('start MicroDebugger block');
this.isInMicroDebugger = true;
this.isNextBreakpointSkipped = false;
line = 'Pausing for a breakpoint...';
} else if (this.isInMicroDebugger && (this.debugEndRegex.exec(line))) {
console.log('ended MicroDebugger block');
logger.log('ended MicroDebugger block');
this.isInMicroDebugger = false;
if (this.isNextBreakpointSkipped) {
line = '\n**Was a bogus breakpoint** Skipping!\n';
Expand All @@ -273,7 +276,7 @@ export class LogOutputManager {
}
} else if (this.isInMicroDebugger) {
if (this.launchConfig.enableDebuggerAutoRecovery && line.startsWith('Break in ')) {
console.log('this block is a break: skipping it');
logger.log('this block is a break: skipping it');
this.isNextBreakpointSkipped = true;
}
line = null;
Expand Down
7 changes: 5 additions & 2 deletions src/commands/BrighterScriptPreviewCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as path from 'path';
import * as querystring from 'querystring';
import { SourceMapConsumer } from 'source-map';
import { languageServerManager } from '../LanguageServerManager';
import { createLogger } from '../logging';

const logger = createLogger('BrighterScriptPreviewCommand');

export const FILE_SCHEME = 'bs-preview';

Expand Down Expand Up @@ -120,7 +123,7 @@ export class BrighterScriptPreviewCommand {
activePreview.previewEditor.revealRange(mappedRange, vscode.TextEditorRevealType.InCenter);
activePreview.previewEditor.selection = new vscode.Selection(mappedRange.start, mappedRange.end);
} catch (e) {
console.error(e);
logger.error(e);
}
}
}
Expand Down Expand Up @@ -172,7 +175,7 @@ export class BrighterScriptPreviewCommand {
activePreview.sourceEditor.revealRange(mappedRange, vscode.TextEditorRevealType.InCenter);
activePreview.sourceEditor.selection = new vscode.Selection(mappedRange.start, mappedRange.end);
} catch (e) {
console.error(e);
logger.error(e);
}
}
}
Expand Down
Loading
Loading