@@ -16,7 +16,8 @@ import Data.List.Extra (
16
16
)
17
17
import Data.Maybe (catMaybes , fromMaybe , isJust )
18
18
import qualified Data.Text as T
19
- import Development.IDE (Action , Rules , noLogging )
19
+ import qualified Data.Text.IO as T
20
+ import Development.IDE (Action , Rules , Priority )
20
21
import Development.IDE.Core.Debouncer (newAsyncDebouncer )
21
22
import Development.IDE.Core.FileStore (makeVFSHandle )
22
23
import Development.IDE.Core.OfInterest (
@@ -49,7 +50,6 @@ import Development.IDE.Plugin (
49
50
import Development.IDE.Plugin.HLS (asGhcIdePlugin )
50
51
import Development.IDE.Session (SessionLoadingOptions , loadSessionWithOptions , setInitialDynFlags , getHieDbLoc , runWithDb )
51
52
import Development.IDE.Types.Location (toNormalizedFilePath' )
52
- import Development.IDE.Types.Logger (Logger )
53
53
import Development.IDE.Types.Options (
54
54
IdeGhcSession ,
55
55
IdeOptions (optCheckParents , optCheckProject , optReportProgress ),
@@ -66,10 +66,11 @@ import qualified Language.LSP.Server as LSP
66
66
import qualified System.Directory.Extra as IO
67
67
import System.Exit (ExitCode (ExitFailure ), exitWith )
68
68
import System.FilePath (takeExtension , takeFileName )
69
- import System.IO (hPutStrLn , hSetEncoding , stderr , stdout , utf8 )
69
+ import System.IO (hSetBuffering , hPutStrLn , hSetEncoding , stderr , stdout , utf8 , BufferMode ( LineBuffering ) )
70
70
import System.Time.Extra (offsetTime , showDuration )
71
71
import Text.Printf (printf )
72
72
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
73
+ import Development.IDE.Types.Logger (Logger (Logger ))
73
74
74
75
data Arguments = Arguments
75
76
{ argsOTMemoryProfiling :: Bool
@@ -89,7 +90,7 @@ instance Default Arguments where
89
90
def = Arguments
90
91
{ argsOTMemoryProfiling = False
91
92
, argFiles = Nothing
92
- , argsLogger = noLogging
93
+ , argsLogger = Logger stderrLogger
93
94
, argsRules = mainRule >> action kick
94
95
, argsGhcidePlugin = mempty
95
96
, argsHlsPlugins = pluginDescToIdePlugins Ghcide. descriptors
@@ -100,9 +101,15 @@ instance Default Arguments where
100
101
, argsGetHieDbLoc = getHieDbLoc
101
102
}
102
103
104
+ -- | Cheap stderr logger that relies on LineBuffering
105
+ stderrLogger :: Priority -> T. Text -> IO ()
106
+ stderrLogger p m =
107
+ T. hPutStrLn stderr $ " [" <> T. pack(show p) <> " ] " <> m
108
+
103
109
defaultMain :: Arguments -> IO ()
104
110
defaultMain Arguments {.. } = do
105
111
pid <- T. pack . show <$> getProcessID
112
+ hSetBuffering stderr LineBuffering
106
113
107
114
let hlsPlugin = asGhcIdePlugin argsDefaultHlsConfig argsHlsPlugins
108
115
hlsCommands = allLspCmdIds' pid argsHlsPlugins
0 commit comments