Skip to content

Commit 486f750

Browse files
committed
Log schema build only in debug, log requested file path
1 parent 1badfa4 commit 486f750

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

DEVELOPING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
#com.intellij.lang.jsgraphql.ide.validation.GraphQLSchemaAnnotator
88
#com.intellij.lang.jsgraphql.schema.GraphQLSchemaChangeTracker:trace
99
#com.intellij.lang.jsgraphql.ide.project.graphqlconfig.GraphQLConfigManager:trace
10+
#com.intellij.lang.jsgraphql.schema.GraphQLRegistryProvider
11+
#com.intellij.lang.jsgraphql.schema.GraphQLSchemaProviderImpl
1012
```

src/main/com/intellij/lang/jsgraphql/schema/GraphQLRegistryProvider.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import com.intellij.lang.jsgraphql.GraphQLSettings;
1515
import com.intellij.lang.jsgraphql.endpoint.ide.project.JSGraphQLEndpointNamedTypeRegistry;
1616
import com.intellij.lang.jsgraphql.ide.introspection.GraphQLIntrospectionService;
17-
import com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper;
1817
import com.intellij.lang.jsgraphql.ide.project.graphqlconfig.GraphQLConfigManager;
18+
import com.intellij.lang.jsgraphql.ide.search.GraphQLPsiSearchHelper;
1919
import com.intellij.lang.jsgraphql.psi.GraphQLFile;
2020
import com.intellij.lang.jsgraphql.psi.GraphQLPsiUtil;
2121
import com.intellij.lang.jsgraphql.types.GraphQLException;
@@ -70,7 +70,8 @@ public static GraphQLRegistryProvider getInstance(@NotNull Project project) {
7070
public GraphQLRegistryProvider(Project project) {
7171
this.project = project;
7272
graphQLFilesScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), GraphQLFileType.INSTANCE);
73-
jsonIntrospectionScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), JsonFileType.INSTANCE);
73+
jsonIntrospectionScope = GlobalSearchScope
74+
.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), JsonFileType.INSTANCE);
7475
psiManager = PsiManager.getInstance(project);
7576
graphQLEndpointNamedTypeRegistry = JSGraphQLEndpointNamedTypeRegistry.getService(project);
7677
graphQLPsiSearchHelper = GraphQLPsiSearchHelper.getInstance(project);
@@ -127,7 +128,13 @@ public GraphQLRegistryInfo getRegistryInfo(@NotNull PsiElement scopedElement) {
127128
}
128129

129130
TypeDefinitionRegistry registry = processor.getCompositeRegistry().buildTypeDefinitionRegistry();
130-
LOG.info(String.format("Registry build completed in %d ms", TimeoutUtil.getDurationMillis(start)));
131+
132+
if (LOG.isDebugEnabled()) {
133+
long durationMillis = TimeoutUtil.getDurationMillis(start);
134+
VirtualFile file = GraphQLPsiUtil.getPhysicalVirtualFile(scopedElement.getContainingFile());
135+
String requester = file != null ? file.getPath() : "<unknown>";
136+
LOG.debug(String.format("Registry build completed in %d ms, requester: %s", durationMillis, requester));
137+
}
131138
return new GraphQLRegistryInfo(registry, errors, processor.isProcessed());
132139
});
133140

@@ -171,7 +178,8 @@ private boolean processJsonFile(GraphQLSchemaDocumentProcessor processor,
171178
} catch (SchemaProblem e) {
172179
errors.add(e);
173180
} catch (Exception e) {
174-
final List<SourceLocation> sourceLocation = Collections.singletonList(new SourceLocation(1, 1, GraphQLPsiUtil.getFileName(psiFile)));
181+
final List<SourceLocation> sourceLocation = Collections.singletonList(
182+
new SourceLocation(1, 1, GraphQLPsiUtil.getFileName(psiFile)));
175183
errors.add(new SchemaProblem(Collections.singletonList(new InvalidSyntaxError(sourceLocation, e.getMessage()))));
176184
}
177185
return true;

src/main/com/intellij/lang/jsgraphql/schema/GraphQLSchemaProviderImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public GraphQLSchemaInfo getSchemaInfo(@NotNull PsiElement psiElement) {
6666
Collection<SchemaValidationError> validationErrors = new SchemaValidator().validateSchema(schema);
6767
List<GraphQLException> errors = validationErrors.isEmpty()
6868
? Collections.emptyList() : Collections.singletonList(new InvalidSchemaException(validationErrors));
69-
LOG.info(String.format("Schema build completed in %d ms", TimeoutUtil.getDurationMillis(start)));
69+
70+
if (LOG.isDebugEnabled()) {
71+
long durationMillis = TimeoutUtil.getDurationMillis(start);
72+
LOG.debug(String.format("Schema build completed in %d ms, requester: %s", durationMillis, containingFileName));
73+
}
7074
return new GraphQLSchemaInfo(schema, errors, registryWithErrors);
7175
} catch (ProcessCanceledException e) {
7276
throw e;

0 commit comments

Comments
 (0)