Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CO-409] Fix withConfigurations usage of WithLogger ==> Allow pure logger to be used. #3697

Merged
merged 2 commits into from
Oct 3, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Oct 2, 2018

Description

Pos.Launcher.Configurations exposes a function:

withConfigurations
    :: (WithLogger m, MonadThrow m, MonadIO m)
    => ...
    -> m r

which highly suggests that the caller Monad m could define its own logger instance and expect withConfigurations to leverage it for whatever logging this function must perform. However:

 usingNamedPureLogger "pure-logger" $ withConfigurations Nothing Nothing False opts

This will fail with a hard LoggingHandler MVar isn't initialized which suggests that some other logger than the one provided is used.
Turns out that withConfigurations relies on withConfigurationsM which perform logging in plain IO only using the given logger's name to do so.
This was most likely introduced when before pure loggers and ability to log in IO were introduced and has now became obsolete.

Linked issue

[CO-409]

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • [ ] CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

KtorZ added 2 commits October 2, 2018 12:01
`Pos.Launcher.Configurations` exposes a function:

```hs
withConfigurations
    :: (WithLogger m, MonadThrow m, MonadIO m)
    => ...
    -> m r
```

which highly suggests that the caller Monad `m` could define its own
logger instance and expect `withConfigurations` to leverage it for
whatever logging this function must perform. However:

```hs
 usingNamedPureLogger "pure-logger" $ withConfigurations Nothing Nothing False opts
```

This will fail with a hard `LoggingHandler MVar isn't initialized` which
suggests that some other logger than the one provided is used.  Turns
out that `withConfigurations` relies on `withConfigurationsM` which
perform logging in plain IO only using the given logger's name to do so.
This was most likely introduced when before pure loggers and ability to
log in IO were introduced and has now became obsolete.
We are missing a simple instance to lift the `NamedPureLogger`
into a MonadIO. This commits solves it.
@KtorZ KtorZ requested a review from coot October 2, 2018 10:05
Copy link
Contributor

@coot coot left a comment

Choose a reason for hiding this comment

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

LGTM

@KtorZ KtorZ merged commit 5509fed into develop Oct 3, 2018
@KtorZ KtorZ deleted the KtorZ/CO-409/fix-withConfigurations-logging branch October 3, 2018 07:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants