Skip to content
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

new takes a Config record (fixes #12) #22

Merged
merged 1 commit into from
Sep 7, 2022
Merged

new takes a Config record (fixes #12) #22

merged 1 commit into from
Sep 7, 2022

Conversation

fumieval
Copy link
Contributor

@fumieval fumieval commented Sep 7, 2022

newの引数としてレコードを取ることにより、APIの拡張性、安定性、わかりやすさを高めた。さらにデフォルト値として stdoutTransportを作成することにより、fast-loggerをインポートすることなく簡単にロガーを作成できるようにした。

@fumieval fumieval requested review from ruicc and ccycle September 7, 2022 04:20
@fumieval fumieval changed the title new takes a Config record new takes a Config record (fixes #12) Sep 7, 2022
Copy link
Contributor

@ccycle ccycle left a comment

Choose a reason for hiding this comment

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

少しですがレビューしてみました、よろしくお願いします。

{ createTransports :: IO [Transport]
, concurrencyLevel :: ConcurrencyLevel
, logLevel :: LogLevel
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Config という名前を使うと他のモジュールと衝突が起きる可能性が大きくなるので、ここの名前を LoggerConfig みたいにLoggerにちなんだものにするといいんじゃないかと思ったのですがどうでしょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

newの時点でけっこう被りやすいので微妙なところですが、確かにLoggerConfigにするデメリットもないのでそうします

, new
, def
Copy link
Contributor

Choose a reason for hiding this comment

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

def を再exportするよりは defaultLoggerConfig として新しく関数を定義したほうが(defの用途をLogger用に制限するという意味で)いいんじゃないかと思いました、ただ自分がDefaultインスタンスを作るメリットをよく分かってないだけな気もします

defaultLoggerConfig :: Config
defaultLoggerConfig = Config
        { createTransports = do
            ls <- newStdoutLoggerSet 4096
            pure [stdoutTransport ls Debug]
        , concurrencyLevel = 1
        , logLevel = Debug
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Herp.Loggerをunqualifiedでインポートする前提で名前を変更しました

Copy link
Contributor

@ruicc ruicc left a comment

Choose a reason for hiding this comment

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

LGTM!

@fumieval fumieval merged commit ca224f6 into master Sep 7, 2022
@ruicc ruicc deleted the logger-config branch September 8, 2022 04:05
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