5
5
{-# LANGUAGE OverloadedStrings #-}
6
6
module Main (main ) where
7
7
8
+ import Control.Arrow ((&&&) )
8
9
import Control.Monad.IO.Class (liftIO )
9
10
import Data.Function ((&) )
10
11
import Data.Text (Text )
12
+ import qualified Development.IDE.Main as GhcideMain
11
13
import Development.IDE.Types.Logger (Doc ,
12
14
Priority (Debug , Error , Info ),
13
15
WithPriority (WithPriority , priority ),
14
16
cfilter , cmapWithPrio ,
15
17
defaultLayoutOptions ,
16
18
layoutPretty ,
17
19
makeDefaultStderrRecorder ,
18
- renderStrict ,
20
+ payload , renderStrict ,
19
21
withDefaultRecorder )
20
22
import qualified Development.IDE.Types.Logger as Logger
21
23
import Ide.Arguments (Arguments (.. ),
@@ -62,24 +64,28 @@ main = do
62
64
liftIO $ (cb1 <> cb2) env
63
65
}
64
66
65
- let (minPriority, logFilePath, includeExamplePlugins) =
67
+ let (argsTesting, minPriority, logFilePath, includeExamplePlugins) =
66
68
case args of
67
69
Ghcide GhcideArguments { argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } ->
68
70
let minPriority = if argsDebugOn || argsTesting then Debug else Info
69
- in (minPriority, argsLogFile, argsExamplePlugin)
70
- _ -> (Info , Nothing , False )
71
+ in (argsTesting, minPriority, argsLogFile, argsExamplePlugin)
72
+ _ -> (False , Info , Nothing , False )
71
73
72
74
withDefaultRecorder logFilePath Nothing minPriority $ \ textWithPriorityRecorder -> do
73
75
let
74
- recorder = cmapWithPrio pretty $ mconcat
76
+ recorder = cmapWithPrio ( pretty &&& id ) $ mconcat
75
77
[textWithPriorityRecorder
76
78
& cfilter (\ WithPriority { priority } -> priority >= minPriority)
79
+ & cmapWithPrio fst
77
80
, lspMessageRecorder
78
81
& cfilter (\ WithPriority { priority } -> priority >= Error )
79
- & cmapWithPrio renderDoc
82
+ & cmapWithPrio ( renderDoc . fst )
80
83
, lspLogRecorder
81
84
& cfilter (\ WithPriority { priority } -> priority >= minPriority)
82
- & cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions)
85
+ & cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions . fst )
86
+ -- do not log heap stats to the LSP log as they interfere with the
87
+ -- ability of lsp-test to detect a stuck server in tests and benchmarks
88
+ & if argsTesting then cfilter (not . heapStats . snd . payload) else id
83
89
]
84
90
plugins = (Plugins. idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
85
91
@@ -96,3 +102,7 @@ renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vsep
96
102
97
103
issueTrackerUrl :: Doc a
98
104
issueTrackerUrl = " https://github.com/haskell/haskell-language-server/issues"
105
+
106
+ heapStats :: Log -> Bool
107
+ heapStats (LogIdeMain (IdeMain. LogIDEMain (GhcideMain. LogHeapStats _))) = True
108
+ heapStats _ = False
0 commit comments