packages feed

canteven-log 2.0.1.0 → 2.0.2.1

raw patch · 3 files changed

+26/−5 lines, 3 filesdep ~basedep ~timePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, time

API changes (from Hackage documentation)

+ Canteven.Log.MonadLog: newLoggingConfig :: String -> LoggingConfig

Files

canteven-log.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                canteven-log-version:             2.0.1.0+version:             2.0.2.1 synopsis:            A canteven way of setting up logging for your program. description:     A library that uses <https://hackage.haskell.org/package/canteven-config canteven-config>@@ -31,7 +31,7 @@   -- other-extensions:   build-depends:     aeson,-    base >= 4.8 && < 4.10,+    base >= 4.8 && < 4.11,     bytestring,     directory,     fast-logger,@@ -39,7 +39,7 @@     monad-logger,     template-haskell,     text,-    time >= 1.5 && <1.7,+    time >= 1.5 && <1.9,     transformers,     yaml   hs-source-dirs:      src
src/Canteven/Log/MonadLog.hs view
@@ -6,13 +6,15 @@      {- Reexports -}     LoggingConfig(LoggingConfig, level, logfile, loggers),-    LoggerDetails(loggerName, loggerPackage, loggerModule, loggerLevel)+    LoggerDetails(loggerName, loggerPackage, loggerModule, loggerLevel),+    newLoggingConfig,     ) where  import Canteven.Log.Types (LoggingConfig(LoggingConfig, logfile,     level, loggers),     LoggerDetails(LoggerDetails, loggerName, loggerPackage,-    loggerModule, loggerLevel))+    loggerModule, loggerLevel),+    newLoggingConfig) import Control.Concurrent (ThreadId, myThreadId) import Control.Monad (when) import Control.Monad.IO.Class (MonadIO, liftIO)
src/Canteven/Log/Types.hs view
@@ -4,6 +4,7 @@     LoggerDetails(..),     LoggingConfig(..),     defaultLogging,+    newLoggingConfig,     ) where  import Control.Monad.Logger (LogLevel(LevelDebug, LevelInfo, LevelWarn,@@ -11,7 +12,17 @@ import Data.Aeson (Value(String, Object), (.:?), (.!=), (.:)) import Data.Maybe (catMaybes, listToMaybe) import Data.Yaml (FromJSON(parseJSON))+import Data.Text (pack) +{-+  A convenience function for creating a LoggingConfig when you just want a+  default LoggingConfig with the specified LogLevel in String form. Useful+  for services that read configuration directly from environment variables+  instead of a configuration file.+-}+newLoggingConfig :: String -> LoggingConfig+newLoggingConfig s = defaultLogging {level = unLP $ read s}+ data LoggingConfig =   LoggingConfig {     level :: LogLevel,@@ -59,6 +70,14 @@   parseJSON (String s) = return (LP (LevelOther s))   parseJSON value = fail $ "Couldn't parse LogLevel from value " ++ show value +{- The provided dervived Read instance for LogLevel isn't very useful -}+instance Read LogPriority where+  readsPrec _ "DEBUG" = [(LP LevelDebug, "")]+  readsPrec _ "INFO" = [(LP LevelInfo, "")]+  readsPrec _ "WARN" = [(LP LevelWarn, "")]+  readsPrec _ "WARNING" = [(LP LevelWarn, "")]+  readsPrec _ "ERROR" = [(LP LevelError, "")]+  readsPrec _ other = [(LP . LevelOther $ pack other, "")]  {- |   A way to set more fined-grained configuration for specific log messages.