pituicat/src/Affection/Logging.hs

41 lines
990 B
Haskell
Raw Normal View History

2017-12-12 12:10:00 +00:00
{-# LANGUAGE CPP #-}
module Affection.Logging where
import Debug.Trace
data LogLevel
2017-12-22 05:28:58 +00:00
= Verbose
| Debug
2017-12-12 12:10:00 +00:00
| Warn
| Error
log :: LogLevel -> String -> a -> a
2017-12-22 05:28:58 +00:00
#if defined(VERBOSE)
log Verbose s = trace ("VERBOSE: " ++ s)
#endif
#if defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
log Debug s = trace ("DEBUG: " ++ s)
#endif
2017-12-22 05:28:58 +00:00
#if defined(WARN) || defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
log Warn s = trace ("WARN: " ++ s)
#endif
2017-12-22 05:28:58 +00:00
#if defined(ERROR) || defined(WARN) || defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
log Error s = trace ("ERROR: " ++ s)
#endif
log _ _ = id
logIO :: LogLevel -> String -> IO ()
2017-12-22 05:28:58 +00:00
#if defined(VERBOSE)
logIO Verbose s = traceIO ("VERBOSE: " ++ s)
#endif
#if defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
logIO Debug s = traceIO ("DEBUG: " ++ s)
#endif
2017-12-22 05:28:58 +00:00
#if defined(WARN) || defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
logIO Warn s = traceIO ("WARN: " ++ s)
#endif
2017-12-22 05:28:58 +00:00
#if defined(ERROR) || defined(WARN) || defined(DEBUG) || defined(VERBOSE)
2017-12-12 12:10:00 +00:00
logIO Error s = traceIO ("ERROR: " ++ s)
#endif
logIO _ _ = return ()