本文整理匯總了TypeScript中vscode-debugadapter.logger.log方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript logger.log方法的具體用法?TypeScript logger.log怎麽用?TypeScript logger.log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode-debugadapter.logger
的用法示例。
在下文中一共展示了logger.log方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getMapForGeneratedPath
/**
* pathToGenerated - an absolute local path or a URL.
* mapPath - a path relative to pathToGenerated.
*/
getMapForGeneratedPath(pathToGenerated: string, mapPath: string, isVSClient = false): Promise<SourceMap> {
let msg = `SourceMaps.getMapForGeneratedPath: Finding SourceMap for ${pathToGenerated} by URI: ${mapPath}`;
if (this._pathMapping) {
msg += ` and webRoot/pathMapping: ${JSON.stringify(this._pathMapping)}`;
}
logger.log(msg);
// For an inlined sourcemap, mapPath is a data URI containing a blob of base64 encoded data, starting
// with a tag like "data:application/json;charset:utf-8;base64,". The data should start after the last comma.
let sourceMapContentsP: Promise<string>;
if (mapPath.indexOf('data:application/json') >= 0) {
// Sourcemap is inlined
logger.log(`SourceMaps.getMapForGeneratedPath: Using inlined sourcemap in ${pathToGenerated}`);
sourceMapContentsP = Promise.resolve(this.getInlineSourceMapContents(mapPath));
} else {
sourceMapContentsP = this.getSourceMapContent(pathToGenerated, mapPath);
}
return sourceMapContentsP.then(contents => {
if (contents) {
try {
// Throws for invalid JSON
return new SourceMap(pathToGenerated, contents, this._pathMapping, this._sourceMapPathOverrides, isVSClient);
} catch (e) {
logger.error(`SourceMaps.getMapForGeneratedPath: exception while processing path: ${pathToGenerated}, sourcemap: ${mapPath}\n${e.stack}`);
return null;
}
} else {
return null;
}
});
}
示例2: applySourceMapPathOverrides
export function applySourceMapPathOverrides(sourcePath: string, sourceMapPathOverrides: ISourceMapPathOverrides, isVSClient = false): string {
const forwardSlashSourcePath = sourcePath.replace(/\\/g, '/');
// Sort the overrides by length, large to small
const sortedOverrideKeys = Object.keys(sourceMapPathOverrides)
.sort((a, b) => b.length - a.length);
// Iterate the key/vals, only apply the first one that matches.
for (let leftPattern of sortedOverrideKeys) {
const rightPattern = sourceMapPathOverrides[leftPattern];
const entryStr = `"${leftPattern}": "${rightPattern}"`;
const asterisks = leftPattern.match(/\*/g) || [];
if (asterisks.length > 1) {
logger.log(`Warning: only one asterisk allowed in a sourceMapPathOverrides entry - ${entryStr}`);
continue;
}
const replacePatternAsterisks = rightPattern.match(/\*/g) || [];
if (replacePatternAsterisks.length > asterisks.length) {
logger.log(`Warning: the right side of a sourceMapPathOverrides entry must have 0 or 1 asterisks - ${entryStr}}`);
continue;
}
// Does it match?
const escapedLeftPattern = utils.escapeRegexSpecialChars(leftPattern, '/*');
const leftRegexSegment = escapedLeftPattern
.replace(/\*/g, '(.*)')
.replace(/\\\\/g, '/');
const leftRegex = new RegExp(`^${leftRegexSegment}$`, 'i');
const overridePatternMatches = forwardSlashSourcePath.match(leftRegex);
if (!overridePatternMatches)
continue;
// Grab the value of the wildcard from the match above, replace the wildcard in the
// replacement pattern, and return the result.
const wildcardValue = overridePatternMatches[1];
let mappedPath = rightPattern.replace(/\*/g, wildcardValue);
mappedPath = path.join(mappedPath); // Fix any ..
if (isVSClient && leftPattern === 'webpack:///./*' && !utils.existsSync(mappedPath)) {
// This is a workaround for a bug in ASP.NET debugging in VisualStudio because the wwwroot is not properly configured
const pathFixingASPNETBug = path.join(rightPattern.replace(/\*/g, path.join('../ClientApp', wildcardValue)));
if (utils.existsSync(pathFixingASPNETBug)) {
++aspNetFallbackCount;
mappedPath = pathFixingASPNETBug;
}
}
logger.log(`SourceMap: mapping ${sourcePath} => ${mappedPath}, via sourceMapPathOverrides entry - ${entryStr}`);
return mappedPath;
}
return sourcePath;
}
示例3: applyPathMappingsToTargetUrlPath
export function applyPathMappingsToTargetUrlPath(scriptUrlPath: string, pathMapping: IPathMapping): string {
if (!pathMapping) {
return '';
}
if (!scriptUrlPath || !scriptUrlPath.startsWith('/')) {
return '';
}
const mappingKeys = Object.keys(pathMapping)
.sort((a, b) => b.length - a.length);
for (let pattern of mappingKeys) {
// empty pattern match nothing use / to match root
if (!pattern) {
continue;
}
const mappingRHS = pathMapping[pattern];
if (pattern[0] !== '/') {
logger.log(`PathMapping keys should be absolute: ${pattern}`);
pattern = '/' + pattern;
}
if (pathMappingPatternMatchesPath(pattern, scriptUrlPath)) {
return toClientPath(pattern, mappingRHS, scriptUrlPath);
}
}
return '';
}
示例4: loadSourceMapContents
private loadSourceMapContents(mapPathOrURL: string): Promise<string> {
let contentsP: Promise<string>;
if (utils.isURL(mapPathOrURL) && !utils.isFileUrl(mapPathOrURL)) {
logger.log(`SourceMaps.loadSourceMapContents: Downloading sourcemap file from ${mapPathOrURL}`);
contentsP = this.downloadSourceMapContents(mapPathOrURL).catch(e => {
logger.log(`SourceMaps.loadSourceMapContents: Could not download sourcemap from ${mapPathOrURL}`);
return null;
});
} else {
mapPathOrURL = utils.canonicalizeUrl(mapPathOrURL);
contentsP = new Promise((resolve, reject) => {
logger.log(`SourceMaps.loadSourceMapContents: Reading local sourcemap file from ${mapPathOrURL}`);
fs.readFile(mapPathOrURL, (err, data) => {
if (err) {
logger.log(`SourceMaps.loadSourceMapContents: Could not read sourcemap file - ` + err.message);
resolve(null);
} else {
resolve(data && data.toString());
}
});
});
}
return contentsP;
}
示例5: resolve
fs.readFile(mapPathOrURL, (err, data) => {
if (err) {
logger.log(`SourceMaps.loadSourceMapContents: Could not read sourcemap file - ` + err.message);
resolve(null);
} else {
resolve(data && data.toString());
}
});
示例6: getComputedSourceRoot
export function getComputedSourceRoot(sourceRoot: string, generatedPath: string, pathMapping: IPathMapping = {}): string {
generatedPath = utils.fileUrlToPath(generatedPath);
let absSourceRoot: string;
if (sourceRoot) {
if (sourceRoot.startsWith('file:///')) {
// sourceRoot points to a local path like "file:///c:/project/src", make it an absolute path
absSourceRoot = utils.canonicalizeUrl(sourceRoot);
} else if (utils.isAbsolute(sourceRoot)) {
// sourceRoot is like "/src", should be like http://localhost/src, resolve to a local path using pathMaping.
// If path mappings do not apply (e.g. node), assume that sourceRoot is actually a local absolute path.
// Technically not valid but it's easy to end up with paths like this.
absSourceRoot = chromeUtils.applyPathMappingsToTargetUrlPath(sourceRoot, pathMapping) || sourceRoot;
// If no pathMapping (node), use sourceRoot as is.
// But we also should handle an absolute sourceRoot for chrome? Does CDT handle that? No it does not, it interprets it as "localhost/full path here"
} else if (path.isAbsolute(generatedPath)) {
// sourceRoot is like "src" or "../src", relative to the script
absSourceRoot = resolveRelativeToFile(generatedPath, sourceRoot);
} else {
// generatedPath is a URL so runtime script is not on disk, resolve the sourceRoot location on disk.
const generatedUrlPath = url.parse(generatedPath).pathname;
const mappedPath = chromeUtils.applyPathMappingsToTargetUrlPath(generatedUrlPath, pathMapping);
const mappedDirname = path.dirname(mappedPath);
absSourceRoot = path.join(mappedDirname, sourceRoot);
}
logger.log(`SourceMap: resolved sourceRoot ${sourceRoot} -> ${absSourceRoot}`);
} else if (path.isAbsolute(generatedPath)) {
absSourceRoot = path.dirname(generatedPath);
logger.log(`SourceMap: no sourceRoot specified, using script dirname: ${absSourceRoot}`);
} else {
// No sourceRoot and runtime script is not on disk, resolve the sourceRoot location on disk
const urlPathname = url.parse(generatedPath).pathname || '/placeholder.js'; // could be debugadapter://123, no other info.
const mappedPath = chromeUtils.applyPathMappingsToTargetUrlPath(urlPathname, pathMapping);
const scriptPathDirname = mappedPath ? path.dirname(mappedPath) : '';
absSourceRoot = scriptPathDirname;
logger.log(`SourceMap: no sourceRoot specified, using webRoot + script path dirname: ${absSourceRoot}`);
}
absSourceRoot = utils.stripTrailingSlash(absSourceRoot);
absSourceRoot = utils.fixDriveLetterAndSlashes(absSourceRoot);
return absSourceRoot;
}
示例7: Promise
contentsP = new Promise((resolve, reject) => {
logger.log(`SourceMaps.loadSourceMapContents: Reading local sourcemap file from ${mapPathOrURL}`);
fs.readFile(mapPathOrURL, (err, data) => {
if (err) {
logger.log(`SourceMaps.loadSourceMapContents: Could not read sourcemap file - ` + err.message);
resolve(null);
} else {
resolve(data && data.toString());
}
});
});
示例8: downloadSourceMapContents
private async downloadSourceMapContents(sourceMapUri: string): Promise<string> {
try {
return await this._downloadSourceMapContents(sourceMapUri);
} catch (e) {
if (url.parse(sourceMapUri).hostname === 'localhost') {
logger.log(`Sourcemaps.downloadSourceMapContents: downlading from 127.0.0.1 instead of localhost`);
return this._downloadSourceMapContents(sourceMapUri.replace('localhost', '127.0.0.1'));
}
throw e;
}
}
示例9: getTargetPathFromClientPath
public getTargetPathFromClientPath(localPath: string): string {
localPath = super.getTargetPathFromClientPath(localPath) || localPath;
if (!this.shouldMapPaths(localPath)) return localPath;
const relPath = relative(this._localRoot, localPath);
if (relPath.startsWith('../')) return '';
let remotePath = join(this._remoteRoot, relPath);
remotePath = utils.fixDriveLetterAndSlashes(remotePath, /*uppercaseDriveLetter=*/true);
logger.log(`Mapped localToRemote: ${localPath} -> ${remotePath}`);
return remotePath;
}
示例10: _downloadSourceMapContents
private async _downloadSourceMapContents(sourceMapUri: string): Promise<string> {
// use sha256 to ensure the hash value can be used in filenames
let cachedSourcemapPath: string;
if (this._enableSourceMapCaching) {
const hash = crypto.createHash('sha256').update(sourceMapUri).digest('hex');
const cachePath = path.join(os.tmpdir(), 'com.microsoft.VSCode', 'node-debug2', 'sm-cache');
cachedSourcemapPath = path.join(cachePath, hash);
const exists = utils.existsSync(cachedSourcemapPath);
if (exists) {
logger.log(`Sourcemaps.downloadSourceMapContents: Reading cached sourcemap file from ${cachedSourcemapPath}`);
return this.loadSourceMapContents(cachedSourcemapPath);
}
}
const responseText = await utils.getURL(sourceMapUri);
if (cachedSourcemapPath && this._enableSourceMapCaching) {
logger.log(`Sourcemaps.downloadSourceMapContents: Caching sourcemap file at ${cachedSourcemapPath}`);
await utils.writeFileP(cachedSourcemapPath, responseText);
}
return responseText;
}