-
Notifications
You must be signed in to change notification settings - Fork 3
Remove some lesser-used reexports from Blammo.Logging #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. < 8000 a class="Link--inTextBlock" data-turbo="false" href="" aria-label="Please reload this page">Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module Blammo.Logging.Setup | ||
( HasLogger (..) | ||
, withLogger | ||
, newLogger | ||
, runLoggerLoggingT | ||
, LoggingT | ||
, WithLogger (..) | ||
, runWithLogger | ||
, newLoggerEnv | ||
, withLoggerEnv | ||
, runSimpleLoggingT | ||
) where | ||
|
||
import Prelude | ||
|
||
import Blammo.Logging | ||
import qualified Blammo.Logging.LogSettings.Env as Env | ||
import Blammo.Logging.Logger | ||
import Blammo.Logging.WithLogger | ||
import Control.Lens (view) | ||
import Control.Monad.IO.Class (MonadIO (..)) | ||
import Control.Monad.IO.Unlift (MonadUnliftIO) | ||
import Control.Monad.Logger.Aeson | ||
import UnliftIO.Exception (finally) | ||
|
||
-- | Construct a 'Logger' configured via environment variables | ||
newLoggerEnv :: MonadIO m => m Logger | ||
newLoggerEnv = liftIO $ newLogger =<< Env.parse | ||
|
||
-- | Initialize logging (configured via environment variables), | ||
-- pass a 'Logger' to the callback, and clean up at the end | ||
-- | ||
-- Applications should avoid calling this more than once in their lifecycle. | ||
withLoggerEnv :: MonadUnliftIO m => (Logger -> m a) -> m a | ||
withLoggerEnv f = liftIO Env.parse >>= \logger -> withLogger logger f | ||
|
||
-- | Construct a 'Logger' configured via environment variables and use it | ||
runSimpleLoggingT :: MonadUnliftIO m => LoggingT m a -> m a | ||
runSimpleLoggingT f = do | ||
logger <- newLoggerEnv | ||
runLoggerLoggingT logger f | ||
|
||
-- | Initialize logging, pass a 'Logger' to the callback, and clean up at the end | ||
-- | ||
-- Applications should avoid calling this more than once in their lifecycle. | ||
runLoggerLoggingT | ||
:: (MonadUnliftIO m, HasLogger env) => env -> LoggingT m a -> m a | ||
runLoggerLoggingT env f = | ||
runLoggingT f (runLogAction logger) `finally` flushLogStr logger | ||
where | ||
logger = view loggerL env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
-- | Simplified out-of-the-box logging | ||
module Blammo.Logging.Simple | ||
( newLoggerEnv | ||
, withLoggerEnv | ||
, runSimpleLoggingT | ||
, module Blammo.Logging | ||
( module Blammo.Logging | ||
, module Blammo.Logging.LogSettings | ||
, module Blammo.Logging.ThreadContext | ||
, module Blammo.Logging.Setup | ||
) where | ||
|
||
import Prelude | ||
|
||
import Blammo.Logging | ||
import qualified Blammo.Logging.LogSettings.Env as Env | ||
import Control.Monad.IO.Class (MonadIO (..)) | ||
import Control.Monad.IO.Unlift (MonadUnliftIO) | ||
|
||
-- | Construct a 'Logger' configured via environment variables | ||
newLoggerEnv :: MonadIO m => m Logger | ||
newLoggerEnv = liftIO $ newLogger =<< Env.parse | ||
|
||
-- | Initialize logging (configured via environment variables), | ||
-- pass a 'Logger' to the callback, and clean up at the end | ||
-- | ||
-- Applications should avoid calling this more than once in their lifecycle. | ||
withLoggerEnv :: MonadUnliftIO m => (Logger -> m a) -> m a | ||
withLoggerEnv f = liftIO Env.parse >>= \logger -> withLogger logger f | ||
|
||
-- | Construct a 'Logger' configured via environment variables and use it | ||
runSimpleLoggingT :: MonadUnliftIO m => LoggingT m a -> m a | ||
runSimpleLoggingT f = do | ||
logger <- newLoggerEnv | ||
runLoggerLoggingT logger f | ||
import Blammo.Logging.LogSettings | ||
import Blammo.Logging.Setup | ||
import Blammo.Logging.ThreadContext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Blammo.Logging.ThreadContext | ||
( MonadMask | ||
, withThreadContext | ||
, myThreadContext | ||
, Pair | ||
chris-martin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) where | ||
|
||
import Control.Monad.Catch (MonadMask) | ||
import Control.Monad.Logger.Aeson (myThreadContext, withThreadContext) | ||
import Data.Aeson.Types (Pair) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.