Skip to content

Commit

Permalink
[ change ] Print log to stderr instead of stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
banacorn committed Dec 12, 2023
1 parent 0e18ff2 commit 8786366
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ main = do
-- https://github.com/agda/agda-language-server/issues/24
hSetEncoding stdout utf8
hSetEncoding stdin utf8

options <- getOptionsFromArgv
if optHelp options
then putStrLn usageMessage
Expand Down
5 changes: 1 addition & 4 deletions src/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ handlers =
result <- Handler.onHover uri pos
responder $ Right result,
notificationHandler SInitialized $ \_not -> pure (),
notificationHandler STextDocumentDidOpen $ \_not -> pure (),
notificationHandler STextDocumentDidSave $ \_not -> pure (),
notificationHandler STextDocumentDidChange $ \_not -> pure (),
notificationHandler SCancelRequest $ \_not -> pure ()
notificationHandler STextDocumentDidOpen $ \_not -> pure ()
-- -- syntax highlighting
-- , requestHandler STextD_cumentSemanticTokensFull $ \req responder -> do
-- result <- Handler.onHighlight (req ^. (params . textDocument . uri))
Expand Down
5 changes: 3 additions & 2 deletions src/Switchboard.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Language.LSP.Server
import Language.LSP.Types hiding (TextDocumentSyncClientCapabilities (..))
import Data.IORef
import Options (Config)
import System.IO (stderr)

data Switchboard = Switchboard
{ sbPrintLog :: ThreadId
Expand Down Expand Up @@ -42,13 +43,13 @@ destroy switchboard = do
killThread (sbRunAgda switchboard)
writeIORef (sbLanguageContextEnv switchboard) Nothing

-- | Keep printing log
-- | Keep printing log to stderr
-- Consumer of `envLogChan`
keepPrintingLog :: Env -> IO ()
keepPrintingLog env = forever $ do
result <- readChan (envLogChan env)
when (envDevMode env) $ do
Text.putStrLn result
Text.hPutStrLn stderr result

-- | Keep sending reactions
-- Consumer of `envResponseChan`
Expand Down

0 comments on commit 8786366

Please sign in to comment.