@@ -67,7 +67,7 @@ import Data.Hashable (hashed)
67
67
data Arguments = Arguments
68
68
{ argsOTMemoryProfiling :: Bool
69
69
, argFiles :: Maybe [FilePath ] -- ^ Nothing: lsp server ; Just: typecheck and exit
70
- , argsLogger :: Logger
70
+ , argsLogger :: IO Logger
71
71
, argsRules :: Rules ()
72
72
, argsHlsPlugins :: IdePlugins IdeState
73
73
, argsGhcidePlugin :: Plugin Config -- ^ Deprecated
@@ -82,7 +82,7 @@ instance Default Arguments where
82
82
def = Arguments
83
83
{ argsOTMemoryProfiling = False
84
84
, argFiles = Nothing
85
- , argsLogger = noLogging
85
+ , argsLogger = stderrLogger
86
86
, argsRules = mainRule >> action kick
87
87
, argsGhcidePlugin = mempty
88
88
, argsHlsPlugins = pluginDescToIdePlugins Ghcide. descriptors
@@ -93,9 +93,18 @@ instance Default Arguments where
93
93
, argsGetHieDbLoc = getHieDbLoc
94
94
}
95
95
96
+ -- | Cheap stderr logger that relies on LineBuffering
97
+ stderrLogger :: IO Logger
98
+ stderrLogger = do
99
+ lock <- newLock
100
+ return $ Logger $ \ p m -> withLock lock $
101
+ T. hPutStrLn stderr $ " [" <> T. pack (show p) <> " ] " <> m
102
+
96
103
defaultMain :: Arguments -> IO ()
97
104
defaultMain Arguments {.. } = do
98
105
pid <- T. pack . show <$> getProcessID
106
+ logger <- argsLogger
107
+ hSetBuffering stderr LineBuffering
99
108
100
109
let hlsPlugin = asGhcIdePlugin argsDefaultHlsConfig argsHlsPlugins
101
110
hlsCommands = allLspCmdIds' pid argsHlsPlugins
@@ -134,7 +143,7 @@ defaultMain Arguments{..} = do
134
143
argsDefaultHlsConfig
135
144
rules
136
145
(Just env)
137
- argsLogger
146
+ logger
138
147
debouncer
139
148
options
140
149
vfs
@@ -171,7 +180,7 @@ defaultMain Arguments{..} = do
171
180
{ optCheckParents = pure NeverCheck
172
181
, optCheckProject = pure False
173
182
}
174
- ide <- initialise argsDefaultHlsConfig rules Nothing argsLogger debouncer options vfs hiedb hieChan
183
+ ide <- initialise argsDefaultHlsConfig rules Nothing logger debouncer options vfs hiedb hieChan
175
184
registerIdeConfiguration (shakeExtras ide) $ IdeConfiguration mempty (hashed Nothing )
176
185
177
186
putStrLn " \n Step 4/4: Type checking the files"
@@ -199,7 +208,7 @@ defaultMain Arguments{..} = do
199
208
Key GhcSessionDeps :
200
209
[k | (_, k) <- HashMap. keys values, k /= Key GhcSessionIO ]
201
210
++ [Key GhcSessionIO ]
202
- measureMemory argsLogger [keys] consoleObserver valuesRef
211
+ measureMemory logger [keys] consoleObserver valuesRef
203
212
204
213
unless (null failed) (exitWith $ ExitFailure (length failed))
205
214
{-# ANN defaultMain ("HLint: ignore Use nubOrd" :: String) #-}
0 commit comments