# Custom logging function

**URL:** <https://forum.canton.network/t/custom-logging-function/4947>\
**Category:** App Development\
**Created:** [July 21, 2022, 3:04pm UTC](https://forum.canton.network/t/custom-logging-function/4947 "2022-07-21T15:04:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prajwalhegde3](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@prajwalhegde3](https://forum.canton.network/u/prajwalhegde3)\
**Post date:** [July 21, 2022, 3:04pm UTC](https://forum.canton.network/t/custom-logging-function/4947/1 "2022-07-21T15:04:42Z")

</div>

Hi All,

I’m trying to write a custom function to log statements into canton log while exercising choices.

However this function will accept currentTimeStamp, contract/choice name and message text as parameters and will concatenate this values and save it into canton log file for debugging purposes

```haskell
custom_logging_function : Time -> Text -> Text -> ()
custom_logging_function timeValue contractValue messageValue = debug "timeStamp : " <> show timeValue <> "contractName : " <> show contractValue <> "messageText : " <> show messageValue

```

But I’m getting an error “Couldn’t match expected type ‘()’ with actual type ‘m0 ()’”

What is wrong with this code, or any better approach that could be used.

Any input is appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [July 21, 2022, 3:27pm UTC](https://forum.canton.network/t/custom-logging-function/4947/2 "2022-07-21T15:27:33Z")

</div>

First, your code is equivalent to `(debug "timeStamp :") <> (show timeValue) <> ...`, which is probably not what you mean.

Second, [`debug` returns a value that is not `()`](https://docs.daml.com/2.3.1/daml/stdlib/Prelude.html#function-da-internal-prelude-debug-24649). I suspect that you are putting your `custom_logging_function` calls under `do`, and therefore you actually want this value to be returned, not dropped on the floor.

Finally, it looks like you want to use `debugRaw` rather than `debug`. However, it might be nicer to define a `data` type with fields named after your strings here, add `deriving (Show)`, and pass a value of that data type to `debug`, rather than manually appending a string together.

---

<div class="post-metadata">

**Author:** ![prajwalhegde3](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@prajwalhegde3](https://forum.canton.network/u/prajwalhegde3)\
**Post date:** [July 22, 2022, 5:06am UTC](https://forum.canton.network/t/custom-logging-function/4947/3 "2022-07-22T05:06:44Z")

</div>

Hi @Stephen

Yes, you are right this function is anticipated to be called under do block and creating a data type for concatenating values would be a cleaner approach.

Thank you for the input. 🙂
