Skip to content

Add getLoggerIO to MonadLog class#46

Merged
23Skidoo merged 1 commit intomasterfrom
logger-io
Apr 9, 2019
Merged

Add getLoggerIO to MonadLog class#46
23Skidoo merged 1 commit intomasterfrom
logger-io

Conversation

@arybczak
Copy link
Copy Markdown
Collaborator

@arybczak arybczak commented Apr 1, 2019

Needed for passing Logger to libraries such as aws or amazonka that operate in the IO monad.

Copy link
Copy Markdown
Contributor

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, 👍 for not forgetting to bump the major version.

localData :: [Pair] -> m a -> m a
-- | Extend the current application domain locally.
localDomain :: T.Text -> m a -> m a
-- | Capture current context of a logger for use in the 'IO' monad.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd reword this comment as "Returns an IO action that logs messages using the current MonadLog context. Useful for interfacing with libraries such as aws or amazonka that accept logging callbacks that operate in IO." to make the purpose of this function more clear.

-- | Extend the current application domain locally.
localDomain :: T.Text -> m a -> m a
-- | Capture current context of a logger for use in the 'IO' monad.
getLoggerIO :: m (UTCTime -> LogLevel -> T.Text -> Value -> IO ())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes MonadLog unimplementable for Non-IO based monads.

I'd rather prefer separate class, e.g. MonadLogIO (though NoLogT m could still have an instance for all m). That wouldn't require major bump, and be a little more flexible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see. I'd like to avoid additional class. How about replacing getLoggerIO with getLoggerEnv :: m LoggerEnv? It's more general as you can use it in conjunction with logMessageIO to get IO logging, but doesn't introduce any IO into the class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arybczak that sounds 👍 if it works for you, though it will still be breaking change :)

@arybczak
Copy link
Copy Markdown
Collaborator Author

arybczak commented Apr 9, 2019

I updated the PR, it should be fine now.

@23Skidoo 23Skidoo merged commit 62c1c66 into master Apr 9, 2019
@23Skidoo 23Skidoo deleted the logger-io branch April 9, 2019 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants