X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FNetwork%2FServices%2FTSN%2FLogging.hs;fp=src%2FNetwork%2FServices%2FTSN%2FLogging.hs;h=f4cf072e1f8f504c792a6e3ef330c8d69cfceb41;hb=364709b7a01a7c2b601ff2eae8237c815a858838;hp=a20a8977ff05d6ddd5719c461b322f8c1dac8b44;hpb=47a56f78983c6c328936e240c30d2f47d26425fe;p=dead%2Fhtsn-common.git diff --git a/src/Network/Services/TSN/Logging.hs b/src/Network/Services/TSN/Logging.hs index a20a897..f4cf072 100644 --- a/src/Network/Services/TSN/Logging.hs +++ b/src/Network/Services/TSN/Logging.hs @@ -1,3 +1,5 @@ +-- | Provide convenience functions for logging to the HSLogger "root" +-- logger. module Network.Services.TSN.Logging ( init_logging, log_debug, @@ -48,12 +50,18 @@ log_warning = warningM rootLoggerName -- logger provided by HSLogger. We remove all of its handlers so -- that it does nothing; then we conditionally add back two handlers -- -- one for syslog, and one for a normal file -- dependent upon --- the 'syslog' and 'log_file' configuration items. +-- the @syslog@ and @log_file@ arguments. -- --- Why don't we take a Configuration as an argument? Because it --- would create circular imports! -init_logging :: Maybe FilePath -> Priority -> Bool -> IO () -init_logging log_file log_level syslog = do +-- If @syslog@ is 'False' and @log_file@ is 'Nothing'; then nothing +-- will be logged and the @log_level@ will essentially be ignored +-- (even though the root logger will have its level set). +-- +init_logging :: Maybe FilePath -- ^ Path to the log file (optional) + -> Bool -- ^ Log to syslog? + -> Priority -- ^ The priority at and above which + -- to log messages. + -> IO () +init_logging log_file syslog log_level = do -- First set the global log level and clear the default handler. let no_handlers = [] :: [GenericHandler a] updateGlobalLogger rootLoggerName (setLevel log_level .