| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.DocTest.Internal.Logging
Synopsis
- type DebugLogger = String -> IO ()
- noLogger :: DebugLogger
- data LogLevel
- parseLogLevel :: String -> Maybe LogLevel
- showJustifiedLogLevel :: LogLevel -> String
- justifyLeft :: Int -> a -> [a] -> [a]
- getThreadName :: ThreadId -> IO String
- formatLog :: String -> 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
Constructors
| 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 | |
| Generic LogLevel Source # | |
| Show LogLevel Source # | |
| NFData LogLevel Source # | |
Defined in Test.DocTest.Internal.Logging | |
| Eq LogLevel Source # | |
| Ord 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.4-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"
getThreadName :: ThreadId -> IO String Source #
Pretty name for a ThreadId. Uses threadLabel if available, otherwise
falls back to show.
formatLog :: String -> LogLevel -> String -> String Source #
Prettily format a log message
threadId <- myThreadId formatLog Debug (show threadId) "some debug message"
"[DEBUG ] [ThreadId 1277462] some debug message"