@@ -102,7 +102,7 @@ data SessionLoadingOptions = SessionLoadingOptions
102
102
-- or 'Nothing' to respect the cradle setting
103
103
, getCacheDirs :: String -> [String ] -> IO CacheDirs
104
104
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
105
- , getInitialGhcLibDir :: FilePath -> IO (Maybe LibDir )
105
+ , getInitialGhcLibDir :: Logger -> FilePath -> IO (Maybe LibDir )
106
106
, fakeUid :: UnitId
107
107
-- ^ unit id used to tag the internal component built by ghcide
108
108
-- To reuse external interface files the unit ids must match,
@@ -140,11 +140,11 @@ loadWithImplicitCradle mHieYaml rootDir = do
140
140
Just yaml -> HieBios. loadCradle yaml
141
141
Nothing -> loadImplicitHieCradle $ addTrailingPathSeparator rootDir
142
142
143
- getInitialGhcLibDirDefault :: FilePath -> IO (Maybe LibDir )
144
- getInitialGhcLibDirDefault rootDir = do
143
+ getInitialGhcLibDirDefault :: Logger -> FilePath -> IO (Maybe LibDir )
144
+ getInitialGhcLibDirDefault logger rootDir = do
145
145
hieYaml <- findCradle def rootDir
146
146
cradle <- loadCradle def hieYaml rootDir
147
- hPutStrLn stderr $ " setInitialDynFlags cradle: " ++ show cradle
147
+ logDebug logger $ T. pack $ " setInitialDynFlags cradle: " ++ show cradle
148
148
libDirRes <- getRuntimeGhcLibDir cradle
149
149
case libDirRes of
150
150
CradleSuccess libdir -> pure $ Just $ LibDir libdir
@@ -156,9 +156,9 @@ getInitialGhcLibDirDefault rootDir = do
156
156
pure Nothing
157
157
158
158
-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir
159
- setInitialDynFlags :: FilePath -> SessionLoadingOptions -> IO (Maybe LibDir )
160
- setInitialDynFlags rootDir SessionLoadingOptions {.. } = do
161
- libdir <- getInitialGhcLibDir rootDir
159
+ setInitialDynFlags :: Logger -> FilePath -> SessionLoadingOptions -> IO (Maybe LibDir )
160
+ setInitialDynFlags logger rootDir SessionLoadingOptions {.. } = do
161
+ libdir <- getInitialGhcLibDir logger rootDir
162
162
dynFlags <- mapM dynFlagsForPrinting libdir
163
163
mapM_ setUnsafeGlobalDynFlags dynFlags
164
164
pure libdir
@@ -167,8 +167,8 @@ setInitialDynFlags rootDir SessionLoadingOptions{..} = do
167
167
-- writing. Actions are picked off one by one from the `HieWriterChan` and executed in serial
168
168
-- by a worker thread using a dedicated database connection.
169
169
-- This is done in order to serialize writes to the database, or else SQLite becomes unhappy
170
- runWithDb :: FilePath -> (HieDb -> IndexQueue -> IO () ) -> IO ()
171
- runWithDb fp k = do
170
+ runWithDb :: Logger -> FilePath -> (HieDb -> IndexQueue -> IO () ) -> IO ()
171
+ runWithDb logger fp k = do
172
172
-- Delete the database if it has an incompatible schema version
173
173
withHieDb fp (const $ pure () )
174
174
`Safe.catch` \ IncompatibleSchemaVersion {} -> removeFile fp
@@ -186,9 +186,9 @@ runWithDb fp k = do
186
186
k <- atomically $ readTQueue chan
187
187
k db
188
188
`Safe.catch` \ e@ SQLError {} -> do
189
- hPutStrLn stderr $ " SQLite error in worker, ignoring: " ++ show e
189
+ logDebug logger $ T. pack $ " SQLite error in worker, ignoring: " ++ show e
190
190
`Safe.catchAny` \ e -> do
191
- hPutStrLn stderr $ " Uncaught error in database worker, ignoring: " ++ show e
191
+ logDebug logger $ T. pack $ " Uncaught error in database worker, ignoring: " ++ show e
192
192
193
193
194
194
getHieDbLoc :: FilePath -> IO FilePath
@@ -361,7 +361,7 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
361
361
res <- loadDLL hscEnv " libm.so.6"
362
362
case res of
363
363
Nothing -> pure ()
364
- Just err -> hPutStrLn stderr $
364
+ Just err -> logDebug logger $ T. pack $
365
365
" Error dynamically loading libm.so.6:\n " <> err
366
366
367
367
-- Make a map from unit-id to DynFlags, this is used when trying to
@@ -425,7 +425,7 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
425
425
let progMsg = " Setting up " <> T. pack (takeBaseName (cradleRootDir cradle))
426
426
<> " (for " <> T. pack lfp <> " )"
427
427
eopts <- mRunLspTCallback lspEnv (withIndefiniteProgress progMsg NotCancellable ) $
428
- cradleToOptsAndLibDir cradle cfp
428
+ cradleToOptsAndLibDir logger cradle cfp
429
429
430
430
logDebug logger $ T. pack (" Session loading result: " <> show eopts)
431
431
case eopts of
@@ -495,11 +495,11 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
495
495
-- This then builds dependencies or whatever based on the cradle, gets the
496
496
-- GHC options/dynflags needed for the session and the GHC library directory
497
497
498
- cradleToOptsAndLibDir :: Show a => Cradle a -> FilePath
498
+ cradleToOptsAndLibDir :: Show a => Logger -> Cradle a -> FilePath
499
499
-> IO (Either [CradleError ] (ComponentOptions , FilePath ))
500
- cradleToOptsAndLibDir cradle file = do
500
+ cradleToOptsAndLibDir logger cradle file = do
501
501
-- Start off by getting the session options
502
- hPutStrLn stderr $ " Output from setting up the cradle " <> show cradle
502
+ logDebug logger $ T. pack $ " Output from setting up the cradle " <> show cradle
503
503
cradleRes <- HieBios. getCompilerOptions file cradle
504
504
case cradleRes of
505
505
CradleSuccess r -> do
0 commit comments