• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode-debugadapter.logger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode-debugadapter.logger的典型用法代码示例。如果您正苦于以下问题:TypeScript logger类的具体用法?TypeScript logger怎么用?TypeScript logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了logger类的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;
            }
        });
    }
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:37,代码来源:sourceMapFactory.ts


示例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;
}
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:54,代码来源:sourceMapUtils.ts


示例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 '';
}
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:30,代码来源:chromeUtils.ts


示例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;
    }
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:25,代码来源:sourceMapFactory.ts


示例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());
     }
 });
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:8,代码来源:sourceMapFactory.ts


示例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;
}
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:45,代码来源:sourceMapUtils.ts


示例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());
         }
     });
 });
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:11,代码来源:sourceMapFactory.ts


示例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;
        }
    }
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:12,代码来源:sourceMapFactory.ts


示例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;
    }
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:13,代码来源:remotePathTransformer.ts


示例10: SourceMap

 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;
     }
 });
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:13,代码来源:sourceMapFactory.ts



注:本文中的vscode-debugadapter.logger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap