module Matterhorn.State.Logging
  ( startLogging
  , stopLogging
  , logSnapshot
  , getLogDestination
  )
where

import           Prelude ()
import           Matterhorn.Prelude

import           Matterhorn.Types


startLogging :: FilePath -> MH ()
startLogging :: FilePath -> MH ()
startLogging FilePath
path = do
    LogManager
mgr <- forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
use (Lens' ChatState ChatResources
csResourcesforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' ChatResources LogManager
crLogManager)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ LogManager -> FilePath -> IO ()
startLoggingToFile LogManager
mgr FilePath
path

stopLogging :: MH ()
stopLogging :: MH ()
stopLogging = do
    LogManager
mgr <- forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
use (Lens' ChatState ChatResources
csResourcesforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' ChatResources LogManager
crLogManager)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ LogManager -> IO ()
stopLoggingToFile LogManager
mgr

logSnapshot :: FilePath -> MH ()
logSnapshot :: FilePath -> MH ()
logSnapshot FilePath
path = do
    LogManager
mgr <- forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
use (Lens' ChatState ChatResources
csResourcesforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' ChatResources LogManager
crLogManager)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ LogManager -> FilePath -> IO ()
requestLogSnapshot LogManager
mgr FilePath
path

getLogDestination :: MH ()
getLogDestination :: MH ()
getLogDestination = do
    LogManager
mgr <- forall s (m :: * -> *) a. MonadState s m => Getting a s a -> m a
use (Lens' ChatState ChatResources
csResourcesforall b c a. (b -> c) -> (a -> b) -> a -> c
.Lens' ChatResources LogManager
crLogManager)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ LogManager -> IO ()
requestLogDestination LogManager
mgr