Skip to content

Commit

Permalink
Add more logging to debug timing
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed May 18, 2024
1 parent 6f9ad7b commit 1e6e7a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Data.String.Interpolate
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Time
import qualified Language.LSP.Protocol.Lens as Lens
import Language.LSP.Protocol.Message hiding (LookupFunc, parseClientMessage, parseServerMessage)
import Language.LSP.Protocol.Types
Expand Down Expand Up @@ -194,9 +195,15 @@ handleStdin :: forall m. (
MonadLoggerIO m, MonadReader TransformerState m, MonadUnliftIO m, MonadFail m
) => Bool -> Bool -> Handle -> MVar ClientRequestMap -> MVar ServerRequestMap -> m ()
handleStdin debugHlsWrites debugClientReads wrappedIn clientReqMap serverReqMap = flip withException (\(e :: SomeException) -> logErrorN [i|HNLS stdin exception: #{e}|]) $ do
when debugClientReads $ do
now <- liftIO getCurrentTime
logDebugN [i|(#{now}) At beginning of handleStdin|]

bytes <- liftIO (parseStream stdin)

when debugClientReads $ logDebugN [i|Read from client: #{bytes}|]
when debugClientReads $ do
now <- liftIO getCurrentTime
logDebugN [i|(#{now}) Read from client: #{bytes}|]

case A.eitherDecode bytes of
Left err -> logErr [i|Couldn't decode incoming message: #{err}. Bytes: #{bytes}.|]
Expand All @@ -215,6 +222,10 @@ handleStdin debugHlsWrites debugClientReads wrappedIn clientReqMap serverReqMap
Nothing -> return m
transformClientReq meth msg >>= writeToHlsHandle debugHlsWrites wrappedIn . A.encode
Right (ClientToServerNot meth msg) -> do
when debugClientReads $ do
now <- liftIO getCurrentTime
logDebugN [i|(#{now}) About to transform client not|]

transformed <- transformClientNot sendExtraNotification meth msg
writeToHlsHandle debugHlsWrites wrappedIn $ A.encode transformed
where
Expand Down
1 change: 1 addition & 0 deletions haskell-notebook-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ executable haskell-notebook-language-server
, safe
, string-interpolate
, text
, time
, unix
, unliftio
, unliftio-core
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ executables:
- process
- retry
- safe
- time
- unix
- unliftio-core

Expand Down

0 comments on commit 1e6e7a4

Please sign in to comment.