-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
new
takes a Config
recordnew
takes a Config
record (fixes #12)
There was a problem hiding this 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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config
という名前を使うと他のモジュールと衝突が起きる可能性が大きくなるので、ここの名前を LoggerConfig
みたいにLoggerにちなんだものにするといいんじゃないかと思ったのですがどうでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newの時点でけっこう被りやすいので微妙なところですが、確かにLoggerConfigにするデメリットもないのでそうします
src/Herp/Logger.hs
Outdated
, new | ||
, def |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Herp.Loggerをunqualifiedでインポートする前提で名前を変更しました
60443df
to
2dec6a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
newの引数としてレコードを取ることにより、APIの拡張性、安定性、わかりやすさを高めた。さらにデフォルト値として stdoutTransportを作成することにより、fast-loggerをインポートすることなく簡単にロガーを作成できるようにした。