packages feed

unclogging 0.1.0.0 → 0.1.0.1

raw patch · 12 files changed

+58/−20 lines, 12 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Effect.Unclog.Json: logText :: LogLevel -> Q Exp
+ Control.Effect.Unclog.Json: logJson :: LogLevel -> Q Exp

Files

CHANGELOG.md view
@@ -3,3 +3,7 @@ ## 0.1.0.0 -- 2024-09-22   * First version. Implements concurrent logging and multiple useful subscribers and the unliftio and fused-effects frontends.++## 0.1.0.1 -- 2024-09-23++* Some documentation updates and add tested-with stanza
README.md view
@@ -8,7 +8,7 @@ Simple, yet extensible concurrent logging system based on publish/subscribe.  The frontend to this library is based on importing a specific logging frontend. Currently there are `Control.Effect.Unclog.{Json,Text}` -and `Unclog.{Json,Text}` for `aeson` and `text` based logging and use with `fused-effects` and `MonadUnliftIO` respectively, +and `Unclog.IO.{Json,Text}` for `aeson` and `text` based logging and use with `fused-effects` and `MonadUnliftIO` respectively,  exposing functions with the same names, `debug`, `info`, `warn` and `fatal` for the four common log levels.  Subscribers watch a channel of logs and are constructed and destructed by the toplevel logging handler, like `runUnclogging` or 
src/Control/Carrier/Unclog.hs view
@@ -16,6 +16,7 @@ import Unclog.Subscriber (Subscriber, refSubscriber, withLoggingWithSubscribers) import UnliftIO (MonadIO (..), MonadUnliftIO, atomically, newIORef, readIORef) +-- | the 'IO' carrier for unclogging type UnclogC :: (Type -> Type) -> Type -> Type newtype UnclogC m r = MkUnclogC {runUnclogC :: PLogChan -> m r}   deriving (Functor, Applicative, Monad, MonadIO, MonadUnliftIO, Alternative, MonadPlus, MonadFail, MonadFix) via ReaderC PLogChan m@@ -33,7 +34,7 @@ runUnclogging subs act = withLoggingWithSubscribers subs (runUnclogC act)  -- | run the logging effect and simply collect the log entries.--- this is useful to check if e.g. a specific log entry was emitted+-- this is useful to check if e.g. a specific log entry was emitted in tests runUncloggingToList :: MonadUnliftIO m => UnclogC m a -> m ([LogEntry], a) runUncloggingToList act = do   ref <- newIORef []
src/Control/Effect/Unclog.hs view
@@ -4,9 +4,11 @@ import Control.Algebra (Has, send) import Unclog.Common (LogEntry) +-- | a logging effect data Log m r where   PublishLogEntry :: (Time -> LogEntry) -> Log m () +-- | publish a log entry that gets supplied a time by the effect interpretation publishLogEntry :: Has Log sig m => (Time -> LogEntry) -> m () publishLogEntry = send . PublishLogEntry {-# INLINE publishLogEntry #-}
src/Control/Effect/Unclog/Json.hs view
@@ -1,8 +1,18 @@ {-# LANGUAGE TemplateHaskell #-}  -- | the @fused-effects@ + @Json@ frontend-module Control.Effect.Unclog.Json where+module Control.Effect.Unclog.Json+  ( -- * logging functions for different log levels+    debug+  , info+  , warn+  , fatal +    -- * helpers+  , logJson+  )+where+ import Control.Effect.Unclog (publishLogEntry) import Data.Aeson import Data.ByteString qualified as BS@@ -10,8 +20,8 @@ import Unclog.Common (LogLevel (..)) import Unclog.Frontend (mkLogEntry) -logText :: LogLevel -> Q Exp-logText lvl =+logJson :: LogLevel -> Q Exp+logJson lvl =   [|     \obj -> do       let entry ts = $(unTypeCode $ mkLogEntry lvl) ts (BS.toStrict . encode $ Object obj)@@ -19,13 +29,13 @@     |]  debug :: Q Exp-debug = logText Debug+debug = logJson Debug  info :: Q Exp-info = logText Info+info = logJson Info  warn :: Q Exp-warn = logText Warn+warn = logJson Warn  fatal :: Q Exp-fatal = logText Fatal+fatal = logJson Fatal
src/Control/Effect/Unclog/Text.hs view
@@ -1,7 +1,17 @@ {-# LANGUAGE TemplateHaskell #-}  -- | the @fused-effects@ + 'Text' frontend-module Control.Effect.Unclog.Text where+module Control.Effect.Unclog.Text+  ( -- * logging functions for different log levels+    debug+  , info+  , warn+  , fatal++    -- * helpers+  , logText+  )+where  import Control.Effect.Unclog (publishLogEntry) import Data.Text.Encoding qualified as T
src/Unclog.hs view
@@ -1,8 +1,7 @@ -- | This module reexports everything you need to accompany an import for your choice of logging frontend ----- -- The frontend to this library is based on importing a specific logging frontend. Currently there are @Control.Effect.Unclog.{Json,Text}@--- and @Unclog.{Json,Text}@ for @aeson@ and @text@ based logging and use with @fused-effects@ and @MonadUnliftIO@ respectively,+-- and @Unclog.IO.{Json,Text}@ for @aeson@ and @text@ based logging and use with @fused-effects@ and @MonadUnliftIO@ respectively, -- exposing functions with the same names, @debug@, @info@, @warn@ and @fatal@ for the four common log levels. -- -- Subscribers watch a channel of logs and are constructed and destructed by the toplevel logging handler, like @runUnclogging@ or
src/Unclog/Common.hs view
@@ -1,4 +1,17 @@-module Unclog.Common where+module Unclog.Common+  ( -- * commonly used types+    LogEntry (..)++    -- ** types that are lifted by template haskell+  , LogLevel (..)+  , Location (..)+  , Position (..)++    -- * channels for publish / subscribe+  , PLogChan (..)+  , SLogChan (..)+  )+where  import Chronos.Types (Time) import Data.ByteString (StrictByteString)
src/Unclog/Frontend.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE ImpredicativeTypes #-} {-# LANGUAGE TemplateHaskellQuotes #-} +-- | functions for splicing in static information and creating log entries from it module Unclog.Frontend   ( -- * generic logging functions     mkLogEntry@@ -18,7 +18,7 @@ import Data.Text qualified as T import Language.Haskell.TH.Syntax (Code, Lift (liftTyped), Loc (Loc), Quasi (qLocation), Quote, bindCode) import Unclog.Common-import UnliftIO+import UnliftIO (STM, writeTChan)  spliceLoc :: (Quote q, Quasi q) => Code q Location spliceLoc = flip bindCode liftTyped do
src/Unclog/Render.hs view
@@ -1,3 +1,4 @@+-- | functions for different ways of rendering log entries to bytestring builders module Unclog.Render   ( -- * rendering to bytestring builders 
src/Unclog/Subscriber.hs view
@@ -1,6 +1,3 @@-{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}--{-# HLINT ignore "Avoid lambda" #-} module Unclog.Subscriber   ( -- * subscribing to a log channel     Subscriber (..)@@ -103,7 +100,7 @@   bracket     acquire     release-    \a -> k (entry a)+    (k . entry) {-# INLINEABLE bracketSubscriber #-}  -- | write log entries to an 'IORef'
unclogging.cabal view
@@ -1,12 +1,13 @@ cabal-version:   3.4 name:            unclogging-version:         0.1.0.0+version:         0.1.0.1 synopsis:   a library which implements easy, concurrent and pretty logging  description:   Simple, yet extensible concurrent logging system based on publish/subscribe. The library is supposed to be easy to use, concurrent and pretty. It is practical for small applications like web-servers or command line programs. +tested-with:     GHC ==9.4.8 || ==9.6.5 || ==9.8.2 license:         AGPL-3.0-or-later license-file:    LICENSE author:          mangoiv