thentos icon indicating copy to clipboard operation
thentos copied to clipboard

Log source code locations in DEBUG level.

Open mf59816 opened this issue 9 years ago • 3 comments

Can logger do whatever assert is doing to get to the source code location, and write that to the log file, too? (If it's easy, that should only happen if log level of the application (not of the log message) is currently set to DEBUG.

mf59816 avatar May 03 '15 06:05 mf59816

not so easy, appearently:

  1. http://augustss.blogspot.de/2014/04/haskell-error-reporting-with-locations.html
  2. https://wiki.haskell.org/Debugging#Stack_trace
  3. ?

mf59816 avatar May 04 '15 15:05 mf59816

Perhaps we should wait for 7.12:

  1. https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack/ImplicitLocations
  2. https://ghc.haskell.org/trac/ghc/ticket/9049

mf59816 avatar May 05 '15 13:05 mf59816

Since ghc-7.10.2, there is a solution:

  • https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/other-type-extensions.html#implicit-parameters
  • https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/other-type-extensions.html#special-implicit-params
{-# LANGUAGE ImplicitParams #-}

import GHC.Stack

f :: String
f = show (?loc :: CallStack)

The down side is that the implicit location parameter must be put there by type annotation on every call site that we want to have on the stack.

fisx avatar Sep 21 '15 05:09 fisx