projects
/
opengl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pretty print message trace
[opengl.git]
/
src
/
Language
/
Haskell
/
LSP
/
Test
/
Parsing.hs
diff --git
a/src/Language/Haskell/LSP/Test/Parsing.hs
b/src/Language/Haskell/LSP/Test/Parsing.hs
index 36349dae864f4fbd63aa82c6016d87da1bd52084..2936b31347f9db69ecf4b1a3951c552336953cfb 100644
(file)
--- a/
src/Language/Haskell/LSP/Test/Parsing.hs
+++ b/
src/Language/Haskell/LSP/Test/Parsing.hs
@@
-10,6
+10,7
@@
import Control.Lens
import Control.Monad.IO.Class
import Control.Monad
import Data.Aeson
import Control.Monad.IO.Class
import Control.Monad
import Data.Aeson
+import Data.Aeson.Encode.Pretty
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Conduit.Parser
import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Conduit.Parser
import Data.Maybe
@@
-42,9
+43,10
@@
satisfy pred = do
if pred x
then do
if pred x
then do
- liftIO $ do
- setSGR [SetColor Foreground Vivid Magenta]
- putStrLn $ "<-- " ++ B.unpack (encodeMsg x)
+ shouldLog <- asks $ logMessages . config
+ liftIO $ when shouldLog $ do
+ setSGR [SetColor Foreground Dull Magenta]
+ putStrLn $ "<-- " ++ B.unpack (encodeMsgPretty x)
setSGR [Reset]
return x
else empty
setSGR [Reset]
return x
else empty
@@
-86,6
+88,9
@@
castMsg = fromMaybe (error "Failed casting a message") . decode . encodeMsg
encodeMsg :: FromServerMessage -> B.ByteString
encodeMsg = encode . genericToJSON (defaultOptions { sumEncoding = UntaggedValue })
encodeMsg :: FromServerMessage -> B.ByteString
encodeMsg = encode . genericToJSON (defaultOptions { sumEncoding = UntaggedValue })
+encodeMsgPretty :: FromServerMessage -> B.ByteString
+encodeMsgPretty = encodePretty . genericToJSON (defaultOptions { sumEncoding = UntaggedValue })
+
-- | Matches if the message is a log message notification or a show message notification/request.
loggingNotification :: Session FromServerMessage
loggingNotification = named "Logging notification" $ satisfy shouldSkip
-- | Matches if the message is a log message notification or a show message notification/request.
loggingNotification :: Session FromServerMessage
loggingNotification = named "Logging notification" $ satisfy shouldSkip