Skip to content

Commit 8fe25bc

Browse files
committed
Fix more putstrln
1 parent a9adef3 commit 8fe25bc

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import Development.IDE.GHC.Compat hiding (Target,
4848
TargetFile, TargetModule)
4949
import qualified Development.IDE.GHC.Compat as GHC
5050
import Development.IDE.GHC.Util
51+
import Development.IDE.Graph (Action)
5152
import Development.IDE.Session.VersionCheck
5253
import Development.IDE.Types.Diagnostics
5354
import Development.IDE.Types.Exports
@@ -56,7 +57,6 @@ import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq,
5657
import Development.IDE.Types.Location
5758
import Development.IDE.Types.Logger
5859
import Development.IDE.Types.Options
59-
import Development.IDE.Graph (Action)
6060
import GHC.Check
6161
import qualified HIE.Bios as HieBios
6262
import HIE.Bios.Environment hiding (getCacheDir)
@@ -152,8 +152,8 @@ setInitialDynFlags logger SessionLoadingOptions{..} = do
152152
-- writing. Actions are picked off one by one from the `HieWriterChan` and executed in serial
153153
-- by a worker thread using a dedicated database connection.
154154
-- This is done in order to serialize writes to the database, or else SQLite becomes unhappy
155-
runWithDb :: FilePath -> (HieDb -> IndexQueue -> IO ()) -> IO ()
156-
runWithDb fp k = do
155+
runWithDb :: Logger -> FilePath -> (HieDb -> IndexQueue -> IO ()) -> IO ()
156+
runWithDb logger fp k = do
157157
-- Delete the database if it has an incompatible schema version
158158
withHieDb fp (const $ pure ())
159159
`catch` \IncompatibleSchemaVersion{} -> removeFile fp
@@ -171,9 +171,9 @@ runWithDb fp k = do
171171
k <- atomically $ readTQueue chan
172172
k db
173173
`catch` \e@SQLError{} -> do
174-
hPutStrLn stderr $ "SQLite error in worker, ignoring: " ++ show e
174+
logWarning logger $ "SQLite error in worker, ignoring: " <> T.pack(show e)
175175
`catchAny` \e -> do
176-
hPutStrLn stderr $ "Uncaught error in database worker, ignoring: " ++ show e
176+
logWarning logger $ "Uncaught error in database worker, ignoring: " <> T.pack(show e)
177177

178178

179179
getHieDbLoc :: FilePath -> IO FilePath
@@ -346,8 +346,8 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
346346
res <- loadDLL hscEnv "libm.so.6"
347347
case res of
348348
Nothing -> pure ()
349-
Just err -> hPutStrLn stderr $
350-
"Error dynamically loading libm.so.6:\n" <> err
349+
Just err -> logError logger $
350+
"Error dynamically loading libm.so.6:\n" <> T.pack err
351351

352352
-- Make a map from unit-id to DynFlags, this is used when trying to
353353
-- resolve imports. (especially PackageImports)

ghcide/src/Development/IDE/LSP/LanguageServer.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
134134
ide <- getIdeState env (makeLSPVFSHandle env) root hiedb hieChan
135135

136136
let initConfig = parseConfiguration params
137-
logInfo (ideLogger ide) $ T.pack $ "Registering ide configuration: " <> show initConfig
137+
l = ideLogger ide
138+
logInfo l $ T.pack $ "Registering ide configuration: " <> show initConfig
138139
registerIdeConfiguration (shakeExtras ide) initConfig
139140

140141
let handleServerException (Left e) = do
@@ -143,7 +144,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
143144
exitClientMsg
144145
throwIO e
145146
handleServerException _ = pure ()
146-
_ <- flip forkFinally handleServerException $ runWithDb dbLoc $ \hiedb hieChan -> do
147+
_ <- flip forkFinally handleServerException $ runWithDb l dbLoc $ \hiedb hieChan -> do
147148
putMVar dbMVar (hiedb,hieChan)
148149
forever $ do
149150
msg <- readChan clientMsgChan

ghcide/src/Development/IDE/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ defaultMain Arguments{..} = do
233233
Check argFiles -> do
234234
dir <- IO.getCurrentDirectory
235235
dbLoc <- getHieDbLoc dir
236-
runWithDb dbLoc $ \hiedb hieChan -> do
236+
runWithDb logger dbLoc $ \hiedb hieChan -> do
237237
-- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
238238
hSetEncoding stdout utf8
239239
hSetEncoding stderr utf8
@@ -301,7 +301,7 @@ defaultMain Arguments{..} = do
301301
Just libdir -> HieDb.runCommand libdir opts{HieDb.database = dbLoc} cmd
302302
Custom projectRoot (IdeCommand c) -> do
303303
dbLoc <- getHieDbLoc projectRoot
304-
runWithDb dbLoc $ \hiedb hieChan -> do
304+
runWithDb logger dbLoc $ \hiedb hieChan -> do
305305
vfs <- makeVFSHandle
306306
sessionLoader <- loadSessionWithOptions argsSessionLoadingOptions "."
307307
let options =

0 commit comments

Comments
 (0)