Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type DebugLogger = String -> IO ()
- noLogger :: DebugLogger
- data LogLevel
- parseLogLevel :: String -> Maybe LogLevel
- showJustifiedLogLevel :: LogLevel -> String
- justifyLeft :: Int -> a -> [a] -> [a]
- formatLog :: ThreadId -> LogLevel -> String -> String
- formatLogHere :: LogLevel -> String -> IO String
- shouldLog :: (?verbosity :: LogLevel) => LogLevel -> Bool
- log :: (?verbosity :: LogLevel) => LogLevel -> String -> IO ()
Documentation
type DebugLogger = String -> IO () Source #
Convenience type alias - not used in this module, but sprinkled across the project.
noLogger :: DebugLogger Source #
Discards any log message
Debug | Intended for debug runs |
Verbose | Intended for debug runs, but without flooding the user with internal messages |
Info | Default log level - print messages user is likely wanting to see |
Warning | Only print warnings |
Error | Only print errors |
Instances
Bounded LogLevel Source # | |
Enum LogLevel Source # | |
Defined in Test.DocTest.Internal.Logging | |
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in Test.DocTest.Internal.Logging | |
Show LogLevel Source # | |
Generic LogLevel Source # | |
NFData LogLevel Source # | |
Defined in Test.DocTest.Internal.Logging | |
type Rep LogLevel Source # | |
Defined in Test.DocTest.Internal.Logging type Rep LogLevel = D1 ('MetaData "LogLevel" "Test.DocTest.Internal.Logging" "doctest-parallel-0.3.0-inplace" 'False) ((C1 ('MetaCons "Debug" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Verbose" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Info" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Warning" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Error" 'PrefixI 'False) (U1 :: Type -> Type)))) |
parseLogLevel :: String -> Maybe LogLevel Source #
Case insensitive
>>>
parseLogLevel "Info"
Just Info>>>
parseLogLevel "info"
Just Info>>>
parseLogLevel "errox"
Nothing
showJustifiedLogLevel :: LogLevel -> String Source #
Pretty print a LogLevel
in a justified manner, i.e., all outputs take the
same amount of characters to display.
>>>
showJustifiedLogLevel Debug
"Debug ">>>
showJustifiedLogLevel Verbose
"Verbose">>>
showJustifiedLogLevel Info
"Info ">>>
showJustifiedLogLevel Warning
"Warning">>>
showJustifiedLogLevel Error
"Error "
justifyLeft :: Int -> a -> [a] -> [a] Source #
Justify a list with a custom fill symbol
>>>
justifyLeft 10 'x' "foo"
"fooxxxxxxx">>>
justifyLeft 3 'x' "foo"
"foo">>>
justifyLeft 2 'x' "foo"
"foo"
formatLog :: ThreadId -> LogLevel -> String -> String Source #
Prettily format a log message
threadId <- myThreadId formatLog Debug threadId "some debug message"
"[DEBUG ] [ThreadId 1277462] some debug message"