Skip to content

Commit

Permalink
added testConfig example for script with different logging level.
Browse files Browse the repository at this point in the history
  • Loading branch information
Montmorency committed Sep 20, 2022
1 parent edab873 commit 777a2c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Guide/scripts.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ The `ihpDefaultConfig` is made available from the `Application.Script.Prelude` i
with your own `Config` data structure. This is particularly useful for adjusting logging levels or
testing new APIs that require certain configuration variables.

You can define a custom configuration (or import one from Config.hs) in your Script
with Logging set to Debug:

```haskell
...
import qualified IHP.Log as Log
import IHP.Log.Types


testConfig :: ConfigBuilder
testConfig = do
logger <- liftIO $ newLogger def {
level = Debug,
formatter = withTimeAndLevelFormatter,
destination = File "Log/App.log" (SizeRotate (Bytes (4 * 1024 * 1024)) 4) defaultBufSize
}
option logger

...
```

and then run the script from ghci:

```haskell
IHP> runScript appConfig runTestNamee
```

## Building a script

In production, you might want to build a script to a binary for performance reasons. Use make like this:
Expand Down

0 comments on commit 777a2c9

Please sign in to comment.