Skip to content

Commit

Permalink
separate package Blammo-wai (#49)
Browse files Browse the repository at this point in the history
* separate package Blammo-wai
* drop LTS 14
* update license year for Blammo
  • Loading branch information
chris-martin authored Jul 22, 2024
1 parent d72bd97 commit a4b38aa
Show file tree
Hide file tree
Showing 23 changed files with 757 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
- uses: haskell-actions/hlint-run@v2
with:
fail-on: warning
path: '["Blammo/src/", "Blammo/tests/"]'
path: '["Blammo/src/", "Blammo/tests/", "Blammo-wai/src/"]'
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
package:
- Blammo
- Blammo-wai

steps:
- uses: actions/checkout@v4
Expand All @@ -30,4 +31,4 @@ jobs:
working-directory: ${{ matrix.package }}
env:
HACKAGE_KEY: ${{ secrets.HACKAGE_UPLOAD_API_KEY }}
STACK_YAML: ../stack-lts-14.27.yaml
STACK_YAML: ../stack-lts-16.31.yaml
92 changes: 92 additions & 0 deletions Blammo-wai/Blammo-wai.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
cabal-version: 1.18

-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

name: Blammo-wai
version: 0.0.0.0
synopsis: Using Blammo with WAI
description: Please see README.md
category: Logging, Web
homepage: https://github.com/freckle/blammo#readme
bug-reports: https://github.com/freckle/blammo/issues
maintainer: Freckle Education
license: MIT
license-file: LICENSE
build-type: Simple
extra-doc-files:
README.md
CHANGELOG.md

source-repository head
type: git
location: https://github.com/freckle/blammo

library
exposed-modules:
Network.Wai.Middleware.Logging
other-modules:
Paths_Blammo_wai
hs-source-dirs:
src
default-extensions:
DerivingStrategies
GeneralizedNewtypeDeriving
LambdaCase
NoImplicitPrelude
OverloadedStrings
RecordWildCards
TypeApplications
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe
build-depends:
Blammo
, aeson
, base <5
, bytestring
, case-insensitive
, clock
, http-types
, text
, unliftio-core
, wai
default-language: Haskell2010
if impl(ghc >= 9.8)
ghc-options: -Wno-missing-role-annotations
if impl(ghc >= 9.2)
ghc-options: -Wno-missing-kind-signatures
if impl(ghc >= 8.10)
ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module

test-suite readme
type: exitcode-stdio-1.0
main-is: README.lhs
other-modules:
Paths_Blammo_wai
default-extensions:
DerivingStrategies
GeneralizedNewtypeDeriving
LambdaCase
NoImplicitPrelude
OverloadedStrings
RecordWildCards
TypeApplications
ghc-options: -Weverything -Wno-all-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -pgmL markdown-unlit
build-depends:
Blammo
, Blammo-wai
, aeson
, base <5
, lens
, markdown-unlit
, text
, wai
, warp
, yesod-core
default-language: Haskell2010
if impl(ghc >= 9.8)
ghc-options: -Wno-missing-role-annotations
if impl(ghc >= 9.2)
ghc-options: -Wno-missing-kind-signatures
if impl(ghc >= 8.10)
ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module
9 changes: 9 additions & 0 deletions Blammo-wai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## [_Unreleased_](https://github.com/freckle/blammo/compare/v0.0.0.1...main)

## [v0.0.0.1](https://github.com/freckle/blammo/compare/0.0.0.0...v0.0.0.1)

...

## [v0.0.0.0](https://github.com/freckle/blammo/tree/v0.0.0.0)

First release
21 changes: 21 additions & 0 deletions Blammo-wai/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022-2024 Renaissance Learning Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
100 changes: 100 additions & 0 deletions Blammo-wai/README.lhs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Blammo-wai

Integration of [Blammo](https://hackage.haskell.org/package/Blammo)
with [wai](https://hackage.haskell.org/package/wai).

<!--
```haskell
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE EmptyDataDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Main (module Main) where
import Prelude
import Control.Exception (displayException)
import Control.Monad (when)
import Data.Aeson
import Data.Text (Text)
import Text.Markdown.Unlit ()
import Control.Lens (lens)
```
-->
```haskell
-- Blammo
import Blammo.Logging
-- wai
import Network.Wai (Middleware)
-- Blammo-wai
import Network.Wai.Middleware.Logging
-- warp
import qualified Network.Wai.Handler.Warp as Warp
-- yesod
import Yesod.Core (Yesod)
import qualified Yesod.Core as Yesod
```
<!--
```haskell
main :: IO ()
main = pure ()
```
-->
```haskell
data App = App
{ appLogger :: Logger
-- etc.
}
instance HasLogger App where
loggerL = lens appLogger $ \x y -> x {appLogger = y}
```
## Integration with WAI
```haskell
waiMiddleware :: App -> Middleware
waiMiddleware app =
addThreadContext ["app" .= ("my-app" :: Text)]
. requestLogger app
. Yesod.defaultMiddlewaresNoLogging
```
## Integration with Warp
```haskell
warpSettings :: App -> Warp.Settings
warpSettings app = Warp.setOnException onEx $ Warp.defaultSettings
where
onEx _req ex =
when (Warp.defaultShouldDisplayException ex)
$ runWithLogger app
$ logError
$ "Warp exception" :# ["exception" .= displayException ex]
```
## Integration with Yesod
<!--
```haskell
instance Yesod.RenderRoute App where
data Route App deriving stock Eq
renderRoute = \case{}
```
-->
```haskell
instance Yesod App where
messageLoggerSource app _logger loc source level msg =
runWithLogger app $ monadLoggerLog loc source level msg
```
1 change: 1 addition & 0 deletions Blammo-wai/README.md
73 changes: 73 additions & 0 deletions Blammo-wai/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Blammo-wai
version: 0.0.0.0
maintainer: Freckle Education
category: Logging, Web
github: freckle/blammo
synopsis: Using Blammo with WAI
description: Please see README.md

extra-doc-files:
- README.md
- CHANGELOG.md

ghc-options:
- -Weverything
- -Wno-all-missed-specialisations
- -Wno-missing-exported-signatures # re-enables missing-signatures
- -Wno-missing-import-lists
- -Wno-missing-local-signatures
- -Wno-monomorphism-restriction
- -Wno-safe
- -Wno-unsafe

when:
- condition: "impl(ghc >= 9.8)"
ghc-options:
- -Wno-missing-role-annotations
- condition: "impl(ghc >= 9.2)"
ghc-options:
- -Wno-missing-kind-signatures
- condition: "impl(ghc >= 8.10)"
ghc-options:
- -Wno-missing-safe-haskell-mode
- -Wno-prepositive-qualified-module

dependencies:
- base < 5

default-extensions:
- DerivingStrategies
- GeneralizedNewtypeDeriving
- LambdaCase
- NoImplicitPrelude
- OverloadedStrings
- RecordWildCards
- TypeApplications

library:
source-dirs: src
dependencies:
- aeson
- Blammo
- bytestring
- case-insensitive
- clock
- http-types
- text
- unliftio-core
- wai

tests:
readme:
main: README.lhs
ghc-options: -pgmL markdown-unlit
dependencies:
- Blammo
- Blammo-wai
- aeson
- lens
- markdown-unlit
- text
- wai
- warp
- yesod-core
9 changes: 2 additions & 7 deletions Blammo/Blammo.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ cabal-version: 1.18
-- see: https://github.com/sol/hpack

name: Blammo
version: 1.2.1.0
version: 2.0.0.0
synopsis: Batteries-included Structured Logging library
description: Please see README.md
category: Utils
category: Logging
homepage: https://github.com/freckle/blammo#readme
bug-reports: https://github.com/freckle/blammo/issues
maintainer: Freckle Education
Expand Down Expand Up @@ -38,7 +38,6 @@ library
Blammo.Logging.Test
Blammo.Logging.WithLogger
Data.Aeson.Compat
Network.Wai.Middleware.Logging
System.Log.FastLogger.Compat
other-modules:
Paths_Blammo
Expand All @@ -57,14 +56,11 @@ library
aeson
, base <5
, bytestring
, case-insensitive
, clock
, containers
, dlist
, envparse
, exceptions
, fast-logger >=3.2.3
, http-types
, lens
, monad-logger-aeson
, mtl
Expand All @@ -74,7 +70,6 @@ library
, unliftio-core
, unordered-containers
, vector
, wai
default-language: Haskell2010
if impl(ghc >= 9.8)
ghc-options: -Wno-missing-role-annotations
Expand Down
5 changes: 5 additions & 0 deletions Blammo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## [_Unreleased_](https://github.com/freckle/blammo/compare/v1.2.1.0...main)

## [v2.0.0.0](https://github.com/freckle/blammo/compare/v1.2.1.0...v2.0.0.0)

- Remove module `Network.Wai.Middleware.Logging`. It is moved to a new
package, `Blammo-wai`.

## [v1.2.1.0](https://github.com/freckle/blammo/compare/1.2.0.0...v1.2.1.0)

- Add `Blammo.Logging.Simple.withLoggerEnv`
Expand Down
2 changes: 1 addition & 1 deletion Blammo/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022 Renaissance Learning Inc
Copyright (c) 2022-2024 Renaissance Learning Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit a4b38aa

Please sign in to comment.