-
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
Coloring #21
Conversation
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.
モジュールを複製して一部分だけ変えるのは、保守性の観点で良くないです。pushLogStrLn
を関数の引数として受け取るなどして重複コードが増えないようにしましょう
src/Herp/Logger/ANSI/Coloring.hs
Outdated
import System.Console.ANSI | ||
|
||
-- https://hackage.haskell.org/package/ansi-terminal-0.11.3/docs/System-Console-ANSI-Types.html#t:SGR | ||
data SGRLogInfo = NotColored | SGRLogInfo [SGR] |
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.
NotColoredが使われていないようですね。仮に使ったとしても SGRLogInfo []
と役割が変わらないため、SGRLogInfo
を定義する必要性は低そうです
|
||
stdoutANSITransport :: LoggerSet -> LogLevel -> Transport | ||
stdoutANSITransport loggerSet transportThreshold = | ||
let name = "stdout" |
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.
この名前はTransportの実装ごとに異なることが期待されています
) | ||
let value = A.pairs $ series <> foldMap (uncurry (.=)) (KM.toList extra) | ||
let json = A.encodingToLazyByteString value | ||
-- pushLogStrLn loggerSet (toLogStr json) |
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.
特別な理由がない限り、コメントアウトしたコードは残さないようにしましょう
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.
masterに #20 がマージされたので、このブランチをリベースし、テスト結果のスクリーンショットの貼り付けをお願いしたいです
herp-logger.cabal
Outdated
@@ -18,6 +18,8 @@ library | |||
Herp.Logger.SentryTransport | |||
Herp.Logger.StdoutTransport | |||
Herp.Logger.Transport | |||
Herp.Logger.ANSI.Coloring | |||
Herp.Logger.StdoutANSITransport |
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.
このモジュールはもう存在しないですね(コミット忘れ?)
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.
すみません、その部分の修正を見落としてました。今pushしたcommitの分で修正しました。
了解です。その際色付きの分のテストケースを |
お願いします! |
src/Herp/Logger/StdoutTransport.hs
Outdated
<> "date" .= T.decodeUtf8 (SB.fromShort date) | ||
<> "message" .= message | ||
) | ||
value = A.pairs $ series <> foldMap (uncurry (.=)) (KM.toList extra) |
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.
valueを束縛する必要がなくなっていますね
tests/stdout.hs
Outdated
loggerLevelTest loggerSet [stdoutTransport loggerSet Debug] Debug | ||
loggerLevelTest loggerSet [stdoutTransport loggerSet Debug] Informational | ||
loggerLevelTest loggerSet [stdoutANSITransport loggerSet Debug] Debug | ||
loggerLevelTest loggerSet [stdoutANSITransport loggerSet Debug] Informational |
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.
スレッショルドのロジックは上でテストされているので、ここで改めてテストする必要はないと思います
コメントありがとうございます、反映させてみました。これだとどうでしょうか? |
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.
ありがとうございます!
あ、マージする前にコミットをまとめて欲しかったですが、まあ今回はいいでしょう |
しまった、忘れてました…次からは気をつけます。 |
LogLevelにあわせて標準出力の一部に色を付ける機能を実装した