Skip to content

Commit 8845867

Browse files
committed
Do not send Heap Stats to the LSP log
It interferes with the ability of lsp-test to detect timeouts in e.g. benchmarks The assumption is that logging them to stderr serves the purpose they were designed for.
1 parent 92f4bd4 commit 8845867

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

exe/Main.hs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Main(main) where
88
import Control.Monad.IO.Class (liftIO)
99
import Data.Function ((&))
1010
import Data.Text (Text)
11+
import qualified Development.IDE.Main as GhcideMain
12+
import qualified Development.IDE.Main.HeapStats as HeapStats
1113
import Development.IDE.Types.Logger (Doc,
1214
Priority (Debug, Error, Info),
1315
WithPriority (WithPriority, priority),
@@ -16,7 +18,7 @@ import Development.IDE.Types.Logger (Doc,
1618
layoutPretty,
1719
makeDefaultStderrRecorder,
1820
renderStrict,
19-
withDefaultRecorder)
21+
withDefaultRecorder, payload)
2022
import qualified Development.IDE.Types.Logger as Logger
2123
import Ide.Arguments (Arguments (..),
2224
GhcideArguments (..),
@@ -32,6 +34,7 @@ import Language.LSP.Types as LSP
3234
import qualified Plugins
3335
#if MIN_VERSION_prettyprinter(1,7,0)
3436
import Prettyprinter (Pretty (pretty), vsep)
37+
import Control.Arrow ((&&&))
3538
#else
3639
import Data.Text.Prettyprint.Doc (Pretty (pretty), vsep)
3740
#endif
@@ -71,15 +74,19 @@ main = do
7174

7275
withDefaultRecorder logFilePath Nothing minPriority $ \textWithPriorityRecorder -> do
7376
let
74-
recorder = cmapWithPrio pretty $ mconcat
77+
recorder = cmapWithPrio (pretty &&& id) $ mconcat
7578
[textWithPriorityRecorder
7679
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
80+
& cmapWithPrio fst
7781
, lspMessageRecorder
7882
& cfilter (\WithPriority{ priority } -> priority >= Error)
79-
& cmapWithPrio renderDoc
83+
& cmapWithPrio (renderDoc . fst)
8084
, lspLogRecorder
8185
& cfilter (\WithPriority{ priority } -> priority >= minPriority)
82-
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
86+
& cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions . fst)
87+
-- do not log heap stats to the LSP log as they interfere with the
88+
-- ability of lsp-test to detect a stuck server in tests and benchmarks
89+
& cfilter (not . heapStats . snd . payload)
8390
]
8491
plugins = (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
8592

@@ -96,3 +103,7 @@ renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vsep
96103

97104
issueTrackerUrl :: Doc a
98105
issueTrackerUrl = "https://github.com/haskell/haskell-language-server/issues"
106+
107+
heapStats :: Log -> Bool
108+
heapStats (LogIdeMain (IdeMain.LogIDEMain (GhcideMain.LogHeapStats _))) = True
109+
heapStats _ = False

0 commit comments

Comments
 (0)