Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Logging / Lifted.hs @ 015278eb

History | View | Annotate | Download (2.2 kB)

1
{-| Ganeti logging functions expressed using MonadBase
2

    
3
This allows to use logging functions without having instances for all
4
possible transformers.
5

    
6
-}
7

    
8
{-
9

    
10
Copyright (C) 2014 Google Inc.
11

    
12
This program is free software; you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation; either version 2 of the License, or
15
(at your option) any later version.
16

    
17
This program is distributed in the hope that it will be useful, but
18
WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
General Public License for more details.
21

    
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
02110-1301, USA.
26

    
27
-}
28

    
29
module Ganeti.Logging.Lifted
30
  ( MonadLog()
31
  , Priority(..)
32
  , L.withErrorLogAt
33
  , L.isDebugMode
34
  , logAt
35
  , logDebug
36
  , logInfo
37
  , logNotice
38
  , logWarning
39
  , logError
40
  , logCritical
41
  , logAlert
42
  , logEmergency
43
  ) where
44

    
45
import Control.Monad.Base
46

    
47
import Ganeti.Logging (MonadLog, Priority(..))
48
import qualified Ganeti.Logging as L
49

    
50
-- * Logging function aliases for MonadBase
51

    
52
-- | A monad that allows logging.
53
logAt :: (MonadLog b, MonadBase b m) => Priority -> String -> m ()
54
logAt p = liftBase . L.logAt p
55

    
56
-- | Log at debug level.
57
logDebug :: (MonadLog b, MonadBase b m) => String -> m ()
58
logDebug = logAt DEBUG
59

    
60
-- | Log at info level.
61
logInfo :: (MonadLog b, MonadBase b m) => String -> m ()
62
logInfo = logAt INFO
63

    
64
-- | Log at notice level.
65
logNotice :: (MonadLog b, MonadBase b m) => String -> m ()
66
logNotice = logAt NOTICE
67

    
68
-- | Log at warning level.
69
logWarning :: (MonadLog b, MonadBase b m) => String -> m ()
70
logWarning = logAt WARNING
71

    
72
-- | Log at error level.
73
logError :: (MonadLog b, MonadBase b m) => String -> m ()
74
logError = logAt ERROR
75

    
76
-- | Log at critical level.
77
logCritical :: (MonadLog b, MonadBase b m) => String -> m ()
78
logCritical = logAt CRITICAL
79

    
80
-- | Log at alert level.
81
logAlert :: (MonadLog b, MonadBase b m) => String -> m ()
82
logAlert = logAt ALERT
83

    
84
-- | Log at emergency level.
85
logEmergency :: (MonadLog b, MonadBase b m) => String -> m ()
86
logEmergency = logAt EMERGENCY