add option to enable logging (#216)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
parent
aef159b097
commit
65b17c9d18
@ -127,12 +127,16 @@ logCfg :: LogConfig
|
|||||||
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
||||||
|
|
||||||
simplexChat :: WithTerminal t => ChatConfig -> ChatOpts -> t -> IO ()
|
simplexChat :: WithTerminal t => ChatConfig -> ChatOpts -> t -> IO ()
|
||||||
simplexChat cfg opts t =
|
simplexChat cfg opts@ChatOpts {logging} t
|
||||||
-- setLogLevel LogInfo -- LogError
|
| logging = do
|
||||||
-- withGlobalLogging logCfg $ do
|
setLogLevel LogInfo -- LogError
|
||||||
initializeNotifications
|
withGlobalLogging logCfg initRun
|
||||||
>>= newChatController cfg opts t
|
| otherwise = initRun
|
||||||
>>= runSimplexChat
|
where
|
||||||
|
initRun =
|
||||||
|
initializeNotifications
|
||||||
|
>>= newChatController cfg opts t
|
||||||
|
>>= runSimplexChat
|
||||||
|
|
||||||
newChatController :: WithTerminal t => ChatConfig -> ChatOpts -> t -> (Notification -> IO ()) -> IO ChatController
|
newChatController :: WithTerminal t => ChatConfig -> ChatOpts -> t -> (Notification -> IO ()) -> IO ChatController
|
||||||
newChatController config@ChatConfig {agentConfig = cfg, dbPoolSize, tbqSize} ChatOpts {dbFile, smpServers} t sendNotification = do
|
newChatController config@ChatConfig {agentConfig = cfg, dbPoolSize, tbqSize} ChatOpts {dbFile, smpServers} t sendNotification = do
|
||||||
|
@ -15,7 +15,8 @@ import System.FilePath (combine)
|
|||||||
|
|
||||||
data ChatOpts = ChatOpts
|
data ChatOpts = ChatOpts
|
||||||
{ dbFile :: String,
|
{ dbFile :: String,
|
||||||
smpServers :: NonEmpty SMPServer
|
smpServers :: NonEmpty SMPServer,
|
||||||
|
logging :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
chatOpts :: FilePath -> Parser ChatOpts
|
chatOpts :: FilePath -> Parser ChatOpts
|
||||||
@ -45,6 +46,11 @@ chatOpts appDir =
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
<*> switch
|
||||||
|
( long "log"
|
||||||
|
<> short 'l'
|
||||||
|
<> help "Enable logging"
|
||||||
|
)
|
||||||
where
|
where
|
||||||
defaultDbFilePath = combine appDir "simplex_v1"
|
defaultDbFilePath = combine appDir "simplex_v1"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user