Skip to content

Conversation

@maksbotan
Copy link

No description provided.


{-# INLINE logInfo #-}
logInfo :: HasCallStack => Text -> Text -> m ()
logInfo a = withFrozenCallStack $ logMsg a INFO
Copy link
Contributor

Choose a reason for hiding this comment

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

а ничего, что на Info будет каждый раз вызываться withFrozenCallStack?

Copy link
Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

А верно ди я понимаю, что во всех методах тогда нужно будет тащить HasCallStack?

Copy link
Author

Choose a reason for hiding this comment

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

Да. Чтобы не тащить руками, я добавил синоним WithBCDLog.
Если написать logMsg прямо в роуте (без кострейнта), выведется правильный модуль и номер строки, но не то название метода. Посмотри в example, там все варианты есть.

Copy link
Contributor

Choose a reason for hiding this comment

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

Давайте не будем оставлять опцию использовать MonadBCDLog напрямую без HasCallStack?

Copy link
Author

Choose a reason for hiding this comment

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

Идея хорошая, но класс все равно надо экспортировать, чтобы инстансы можно было писать. Можно его переименовать так, чтобы не хотелось использовать, MonadLogImpl например.

Я буду переделывать этот после обсуждения вчера с @ozzzzz, если что.

@@ -0,0 +1,68 @@
{-# LANGUAGE MonoLocalBinds #-}

module System.BCD.Log.Class where
Copy link
Contributor

Choose a reason for hiding this comment

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

экспорты

Copy link
Author

Choose a reason for hiding this comment

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

В каждом модуле, кроме модулей Internal должны присутствовать списки экспорта.

Но ладно, я добавлю)

@maksbotan maksbotan force-pushed the maksbotan/fast-logger branch from 60bce85 to 475bb05 Compare September 16, 2019 06:59
--
-- All methods in this class preserve call stack information from their call site.
--
class MonadBCDLog m where
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Давайте не будем оставлять опцию использовать MonadBCDLog напрямую без HasCallStack?

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.

4 participants