packages feed

co-log-core 0.2.1.1 → 0.3.0.0

raw patch · 8 files changed

+94/−32 lines, 8 filesdep ~basedep ~doctestPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, doctest

API changes (from Hackage documentation)

- Colog.Core.Severity: instance GHC.Arr.Ix Colog.Core.Severity.Severity
+ Colog.Core.IO: logFlush :: MonadIO m => Handle -> LogAction m a
+ Colog.Core.Severity: instance GHC.Ix.Ix Colog.Core.Severity.Severity

Files

CHANGELOG.md view
@@ -3,6 +3,23 @@ `co-log-core` uses [PVP Versioning][1]. The change log is available [on GitHub][2]. +## 🎃 0.3.0.0 — Oct 29, 2021++* [#223](https://github.com/co-log/co-log/pull/223):+  Support GHC-9.0.1.+* [#176](https://github.com/co-log/co-log/issues/176):+  Add `logFlush` action to flush the given `Handle`.++  __Breaking change:__ All `withLog*File` functions how flush handle+  after logging each message. Now you'll see logs in the file+  immediately.++  __Migration guide:__ If you rely on the previous behaviour, then+  copy-paste corresponding functions and remove flushing.++* Update maintainers information to the new+  [Co-Log](https://github.com/co-log) organization.+ ## 0.2.1.1 — Apr 18, 2020  * [#186](https://github.com/kowainik/co-log/issues/186):
README.md view
@@ -1,9 +1,11 @@ # co-log +![Co-logo](https://user-images.githubusercontent.com/8126674/80955687-92f21a80-8df7-11ea-90d3-422dafdc8391.png)+ [![GitHub CI](https://github.com/kowainik/co-log/workflows/CI/badge.svg)](https://github.com/kowainik/co-log/actions) [![Build status](https://img.shields.io/travis/kowainik/co-log.svg?logo=travis)](https://travis-ci.org/kowainik/co-log)-[![Windows build](https://ci.appveyor.com/api/projects/status/github/kowainik/co-log?branch=master&svg=true)](https://ci.appveyor.com/project/kowainik/co-log)-[![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/kowainik/co-log/blob/master/LICENSE)+[![Windows build](https://ci.appveyor.com/api/projects/status/github/kowainik/co-log?branch=main&svg=true)](https://ci.appveyor.com/project/kowainik/co-log)+[![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/kowainik/co-log/blob/main/LICENSE)   |                   |                                    |                                           |                                                       |@@ -45,8 +47,8 @@ created the tutorial series which introduces the main concepts behind `co-log` smoothly: -* [Intro: Using `LogAction`](https://github.com/kowainik/co-log/blob/master/co-log/tutorials/1-intro/Intro.md)-* [Using custom monad that stores `LogAction` inside its environment](https://github.com/kowainik/co-log/blob/master/co-log/tutorials/2-custom/Custom.md)+* [Intro: Using `LogAction`](https://github.com/kowainik/co-log/blob/main/co-log/tutorials/1-intro/Intro.md)+* [Using custom monad that stores `LogAction` inside its environment](https://github.com/kowainik/co-log/blob/main/co-log/tutorials/2-custom/Custom.md)  `co-log` also cares about concurrent logging. For this purpose we have the `concurrent-playground` executable where we experiment with different multithreading scenarios to test the library's behavior.
co-log-core.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                co-log-core-version:             0.2.1.1+version:             0.3.0.0 synopsis:            Composable Contravariant Comonadic Logging Library description:     This package provides core types and functions to work with the @LogAction@ data type which is both simple and powerful.@@ -21,13 +21,13 @@     * [co-log-polysemy](http://hackage.haskell.org/package/co-log-polysemy): extensible       effects implementation based on @polysemy@. -homepage:            https://github.com/kowainik/co-log-bug-reports:         https://github.com/kowainik/co-log/issues+homepage:            https://github.com/co-log/co-log-core+bug-reports:         https://github.com/co-log/co-log-core/issues license:             MPL-2.0 license-file:        LICENSE author:              Dmitrii Kovanikov maintainer:          Kowainik <xrom.xkov@gmail.com>-copyright:           2018-2020 Kowainik+copyright:           2018-2020 Kowainik, 2021 Co-Log category:            Logging, Contravariant, Comonad build-type:          Simple stability:           stable@@ -36,15 +36,16 @@ tested-with:         GHC == 8.2.2                      GHC == 8.4.4                      GHC == 8.6.5-                     GHC == 8.8.3-                     GHC == 8.10.1+                     GHC == 8.8.4+                     GHC == 8.10.7+                     GHC == 9.0.1  source-repository head   type:                git-  location:            https://github.com/kowainik/co-log.git+  location:            https://github.com/co-log/co-log-core.git  common common-options-  build-depends:       base >= 4.10.1.0 && < 4.15+  build-depends:       base >= 4.10.1.0 && < 4.16    ghc-options:         -Wall                        -Wcompat@@ -91,5 +92,5 @@   type:                 exitcode-stdio-1.0   hs-source-dirs:       test   main-is:              Doctests.hs-  build-depends:        doctest ^>= 0.16.0+  build-depends:        doctest >= 0.16.0 && < 0.19                       , Glob ^>= 0.10.0
src/Colog/Core.hs view
@@ -1,7 +1,10 @@ {- |-Copyright:  (c) 2018-2020 Kowainik-SPDX-License-Identifier: MPL-2.0-Maintainer: Kowainik <xrom.xkov@gmail.com>+Module                  : Colog.Core+Copyright               : (c) 2018-2020 Kowainik, 2021 Co-Log+SPDX-License-Identifier : MPL-2.0+Maintainer              : Co-Log <xrom.xkov@gmail.com>+Stability               : Stable+Portability             : Portable  Exports all core functionality. @co-log-core@ is a lightweight package that defines only core data type and various combinators to work with it.@@ -25,6 +28,7 @@ * __"Colog.Core.IO":__ basic loggers that work with 'Control.Monad.IO.Class.MonadIO' and 'String'. * __"Colog.Core.Severity":__ logger severity. -}+ module Colog.Core        ( module Colog.Core.Action        , module Colog.Core.Class
src/Colog/Core/Action.hs view
@@ -6,9 +6,12 @@ {-# LANGUAGE UndecidableInstances #-}  {- |-Copyright:  (c) 2018-2020 Kowainik-SPDX-License-Identifier: MPL-2.0-Maintainer: Kowainik <xrom.xkov@gmail.com>+Module                  : Colog.Core.Action+Copyright               : (c) 2018-2020 Kowainik, 2021 Co-Log+SPDX-License-Identifier : MPL-2.0+Maintainer              : Co-Log <xrom.xkov@gmail.com>+Stability               : Stable+Portability             : Portable  Implements core data types and combinators for logging actions. -}
src/Colog/Core/Class.hs view
@@ -3,9 +3,12 @@ {-# LANGUAGE Rank2Types            #-}  {- |-Copyright:  (c) 2018-2020 Kowainik-SPDX-License-Identifier: MPL-2.0-Maintainer: Kowainik <xrom.xkov@gmail.com>+Module                  : Colog.Core.Class+Copyright               : (c) 2018-2020 Kowainik, 2021 Co-Log+SPDX-License-Identifier : MPL-2.0+Maintainer              : Co-Log <xrom.xkov@gmail.com>+Stability               : Stable+Portability             : Portable  Provides type class for values that has access to 'LogAction'. -}
src/Colog/Core/IO.hs view
@@ -1,9 +1,12 @@ {-# LANGUAGE CPP #-}  {- |-Copyright:  (c) 2018-2020 Kowainik-SPDX-License-Identifier: MPL-2.0-Maintainer: Kowainik <xrom.xkov@gmail.com>+Module                  : Colog.Core.IO+Copyright               : (c) 2018-2020 Kowainik+SPDX-License-Identifier : MPL-2.0+Maintainer              : Co-Log <xrom.xkov@gmail.com>+Stability               : Stable+Portability             : Portable  Introduces logging actions working in 'MonadIO'. These actions are very basic and inefficient because they use the 'String' data type. If you don't want to@@ -27,11 +30,13 @@           -- * Various combinators        , liftLogIO+       , logFlush        ) where  import Colog.Core.Action (LogAction (..)) import Control.Monad.IO.Class (MonadIO, liftIO)-import System.IO (Handle, IOMode (AppendMode), hPrint, hPutStrLn, stderr, withFile)+import Data.Semigroup ((<>))+import System.IO (Handle, IOMode (AppendMode), hFlush, hPrint, hPutStrLn, stderr, withFile)   {- $setup@@ -43,6 +48,8 @@ ----------------------------------------------------------------------------  {- | Action that prints 'String' to stdout.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logStringStdout <& "foo" foo@@ -53,6 +60,8 @@ {-# SPECIALIZE logStringStdout :: LogAction IO String #-}  {- | Action that prints 'String' to stderr.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logStringStderr <& "foo" foo@@ -63,6 +72,8 @@ {-# SPECIALIZE logStringStderr :: LogAction IO String #-}  {- | Action that prints 'String' to 'Handle'.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logStringHandle stderr <& "foo" foo@@ -77,7 +88,7 @@ file only once at the start of the application and write to 'Handle' instead of opening file each time we need to write to it. -Opens file in 'AppendMode'.+Opens file in 'AppendMode'. Automatically flushes the output buffer.  #ifndef mingw32_HOST_OS @@ -88,7 +99,8 @@ #endif -} withLogStringFile :: MonadIO m => FilePath -> (LogAction m String -> IO r) -> IO r-withLogStringFile path action = withFile path AppendMode $ action . logStringHandle+withLogStringFile path action = withFile path AppendMode $ \handle ->+  action (logStringHandle handle <> logFlush handle) {-# INLINE withLogStringFile #-} {-# SPECIALIZE withLogStringFile :: FilePath -> (LogAction IO String -> IO r) -> IO r #-} @@ -97,6 +109,8 @@ ----------------------------------------------------------------------------  {- | Action that prints to stdout using 'Show'.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logPrint <& 5 5@@ -107,6 +121,8 @@ {-# SPECIALIZE logPrint :: Show a => LogAction IO a #-}  {- | Action that prints to stderr using 'Show'.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logPrintStderr <& 5 5@@ -117,6 +133,8 @@ {-# SPECIALIZE logPrintStderr :: Show a => LogAction IO a #-}  {- | Action that prints to a 'Handle' using 'Show'.+This action does not flush the output buffer.+If buffering mode is block buffering, the effect of this action can be delayed.  >>> logPrintHandle stderr <& 5 5@@ -133,7 +151,8 @@     => FilePath     -> (LogAction m a -> IO r)     -> IO r-withLogPrintFile path action = withFile path AppendMode $ action . logPrintHandle+withLogPrintFile path action = withFile path AppendMode $ \handle ->+  action (logPrintHandle handle <> logFlush handle) {-# INLINE withLogPrintFile #-} {-# SPECIALIZE withLogPrintFile :: Show a => FilePath -> (LogAction IO a -> IO r) -> IO r #-} @@ -150,3 +169,13 @@ liftLogIO :: MonadIO m => LogAction IO msg -> LogAction m msg liftLogIO (LogAction action) = LogAction (liftIO . action) {-# INLINE liftLogIO #-}++{- | This action can be used in combination with other actions to flush+a handle every time you log anything.++@since 0.3.0.0+-}+logFlush :: MonadIO m => Handle -> LogAction m a+logFlush handle = LogAction $ const $ liftIO $ hFlush handle+{-# INLINE logFlush #-}+{-# SPECIALIZE logFlush :: Handle -> LogAction IO a #-}
src/Colog/Core/Severity.hs view
@@ -1,9 +1,12 @@ {-# LANGUAGE PatternSynonyms #-}  {- |-Copyright:  (c) 2018-2020 Kowainik-SPDX-License-Identifier: MPL-2.0-Maintainer: Kowainik <xrom.xkov@gmail.com>+Module                  : Colog.Core.Severity+Copyright               : (c) 2018-2020 Kowainik, 2021 Co-Log+SPDX-License-Identifier : MPL-2.0+Maintainer              : Co-Log <xrom.xkov@gmail.com>+Stability               : Stable+Portability             : Portable  This module introduces 'Severity' data type for expressing how severe the message is. Also, it contains useful functions and patterns for work with 'Severity'.