-
Notifications
You must be signed in to change notification settings - Fork 0
version 0.1.2.0: MTL style logging, fast-logger #4
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| {-# INLINE logInfo #-} | ||
| logInfo :: HasCallStack => Text -> Text -> m () | ||
| logInfo a = withFrozenCallStack $ logMsg a INFO |
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.
а ничего, что на Info будет каждый раз вызываться withFrozenCallStack?
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.
Думаю ничего, но если хочешь могу побенчмаркать.
Без этого никуда, потому что иначе logMsg прочитает стек вот прямо в этой строчке, а не там где вызвали logInfo.
Я брал отсюда: http://hackage.haskell.org/package/co-log-0.3.0.0/docs/src/Colog.Message.html#log
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.
А верно ди я понимаю, что во всех методах тогда нужно будет тащить HasCallStack?
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.
Да. Чтобы не тащить руками, я добавил синоним WithBCDLog.
Если написать logMsg прямо в роуте (без кострейнта), выведется правильный модуль и номер строки, но не то название метода. Посмотри в example, там все варианты есть.
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.
Давайте не будем оставлять опцию использовать MonadBCDLog напрямую без HasCallStack?
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.
Идея хорошая, но класс все равно надо экспортировать, чтобы инстансы можно было писать. Можно его переименовать так, чтобы не хотелось использовать, MonadLogImpl например.
Я буду переделывать этот после обсуждения вчера с @ozzzzz, если что.
src/System/BCD/Log/Class.hs
Outdated
| @@ -0,0 +1,68 @@ | |||
| {-# LANGUAGE MonoLocalBinds #-} | |||
|
|
|||
| module System.BCD.Log.Class where | |||
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.
В каждом модуле, кроме модулей
Internalдолжны присутствовать списки экспорта.
Но ладно, я добавлю)
60bce85 to
475bb05
Compare
| -- | ||
| -- All methods in this class preserve call stack information from their call site. | ||
| -- | ||
| class MonadBCDLog m where |
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.
Предлагаю просто MonadLog назвать
| -- | ||
| class MonadBCDLog m where | ||
| -- | General method to log a message with any 'Level'. | ||
| logMsg |
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.
logM?)
|
|
||
| {-# INLINE logInfo #-} | ||
| logInfo :: HasCallStack => Text -> Text -> m () | ||
| logInfo a = withFrozenCallStack $ logMsg a INFO |
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.
Давайте не будем оставлять опцию использовать MonadBCDLog напрямую без HasCallStack?
No description provided.