Skip to content

Commit 8cf8eb1

Browse files
committed
Add some logging to the sys.watchFile and sys.watchDirectory
1 parent e293232 commit 8cf8eb1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/compiler/sys.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ namespace ts {
379379
/*@internal*/
380380
export const ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
381381

382+
/*@internal*/
383+
export let sysLog: (s: string) => void = noop;
384+
382385
/*@internal*/
383386
export interface RecursiveDirectoryWatcherHost {
384387
watchDirectory: HostWatchDirectory;
@@ -1053,6 +1056,7 @@ namespace ts {
10531056
* @param createWatcher
10541057
*/
10551058
function invokeCallbackAndUpdateWatcher(createWatcher: () => FileWatcher) {
1059+
sysLog(`sysLog:: ${fileOrDirectory}:: Changing watcher to ${createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing"}FileSystemEntryWatcher`);
10561060
// Call the callback for current directory
10571061
callback("rename", "");
10581062

@@ -1115,6 +1119,7 @@ namespace ts {
11151119
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
11161120
*/
11171121
function watchPresentFileSystemEntryWithFsWatchFile(): FileWatcher {
1122+
sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`);
11181123
return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval);
11191124
}
11201125

src/compiler/watchUtilities.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ namespace ts {
370370
const createFileWatcher: CreateFileWatcher<WatchFileHost, PollingInterval, FileWatcherEventKind, never, X, Y> = getCreateFileWatcher(watchLogLevel, watchFile);
371371
const createFilePathWatcher: CreateFileWatcher<WatchFileHost, PollingInterval, FileWatcherEventKind, Path, X, Y> = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
372372
const createDirectoryWatcher: CreateFileWatcher<WatchDirectoryHost, WatchDirectoryFlags, undefined, never, X, Y> = getCreateFileWatcher(watchLogLevel, watchDirectory);
373+
if (watchLogLevel === WatchLogLevel.Verbose && sysLog === noop) {
374+
sysLog = s => log(s);
375+
}
373376
return {
374377
watchFile: (host, file, callback, pollingInterval, detailInfo1, detailInfo2) =>
375378
createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo),

0 commit comments

Comments
 (0)