thentos
thentos copied to clipboard
Log source code locations in DEBUG level.
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.
not so easy, appearently:
- http://augustss.blogspot.de/2014/04/haskell-error-reporting-with-locations.html
- https://wiki.haskell.org/Debugging#Stack_trace
- ?
Perhaps we should wait for 7.12:
- https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack/ImplicitLocations
- https://ghc.haskell.org/trac/ghc/ticket/9049
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.