Skip to content
Browse files

feat(language-service): enable logging on TypeScriptHost (#32645)

This PR adds loggin methods to TypeScriptHost so that proper logging
to file could be done.
Three new methods are added: log(), error(), and debug().

PR Close #32645
  • Loading branch information...
kyliau authored and kara committed Sep 12, 2019
1 parent 3c7da76 commit e82f56b96f2beff420354dbb10ad84a99ef03325
Showing with 40 additions and 0 deletions.
  1. +40 −0 packages/language-service/src/typescript_host.ts
@@ -9,6 +9,7 @@
import {AotSummaryResolver, CompileDirectiveSummary, CompileMetadataResolver, CompileNgModuleMetadata, CompilePipeSummary, CompilerConfig, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, FormattedError, FormattedMessageChain, HtmlParser, I18NHtmlParser, JitSummaryResolver, Lexer, NgAnalyzedModules, NgModuleResolver, ParseTreeResult, Parser, PipeResolver, ResourceLoader, StaticReflector, StaticSymbol, StaticSymbolCache, StaticSymbolResolver, TemplateParser, analyzeNgModules, createOfflineCompileUrlResolver, isFormattedError} from '@angular/compiler';
import {SchemaMetadata, ViewEncapsulation, ɵConsole as Console} from '@angular/core';
import * as ts from 'typescript';
import * as tss from 'typescript/lib/tsserverlibrary';

import {AstResult, isAstResult} from './common';
import {createLanguageService} from './language_service';
@@ -525,6 +526,45 @@ export class TypeScriptServiceHost implements LanguageServiceHost {

* Log the specified `msg` to file at INFO level. If logging is not enabled
* this method is a no-op.
* @param msg Log message
log(msg: string) {
if (this.tsLsHost.log) {

* Log the specified `msg` to file at ERROR level. If logging is not enabled
* this method is a no-op.
* @param msg error message
error(msg: string) {
if (this.tsLsHost.error) {

* Log debugging info to file at INFO level, only if verbose setting is turned
* on. Otherwise, this method is a no-op.
* @param msg debugging message
debug(msg: string) {
const project = this.tsLsHost as tss.server.Project;
if (!project.projectService) {
// tsLsHost is not a Project
const {logger} = project.projectService;
if (logger.hasLevel(tss.server.LogLevel.verbose)) {;

function findSuitableDefaultModule(modules: NgAnalyzedModules): CompileNgModuleMetadata|undefined {

0 comments on commit e82f56b

Please sign in to comment.
You can’t perform that action at this time.