Merge branch 'av/core-loglevel' into av/core-loglevel-android

This commit is contained in:
Evgeny Poberezkin 2024-12-06 16:57:46 +00:00
commit 3655ab85e6
No known key found for this signature in database
GPG key ID: 494BDDD9A28B577D

View file

@ -54,7 +54,7 @@ import Simplex.Messaging.Encoding.String
import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, sumTypeJSON)
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType (..), BasicAuth (..), CorrId (..), ProtoServerWithAuth (..), ProtocolServer (..))
import Simplex.Messaging.Util (catchAll, liftEitherWith, safeDecodeUtf8)
import System.IO (utf8)
import System.IO (BufferMode (..), hSetBuffering, stderr, stdout, utf8)
import System.Timeout (timeout)
data DBMigrationResult
@ -267,7 +267,10 @@ handleErr :: IO () -> IO String
handleErr a = (a $> "") `catch` (pure . show @SomeException)
chatSendCmd :: ChatController -> B.ByteString -> IO JSONByteString
chatSendCmd cc = withGlobalLogging logCfg . chatSendRemoteCmd cc Nothing
chatSendCmd cc cmd = withGlobalLogging logCfg $ do
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
chatSendRemoteCmd cc Nothing cmd
chatSendRemoteCmd :: ChatController -> Maybe RemoteHostId -> B.ByteString -> IO JSONByteString
chatSendRemoteCmd cc rh s = J.encode . APIResponse Nothing rh <$> runReaderT (execChatCommand rh s) cc