# Debugging (run time on/off) at Source Firmware code for photon

**URL:** <https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882>\
**Category:** Firmware\
**Created:** [July 28, 2015, 12:24pm UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882 "2015-07-28T12:24:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yianmar](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/yianmar/32/2990_2.png) [@yianmar](https://community.particle.io/u/yianmar)\
**Post date:** [July 28, 2015, 12:24pm UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/1 "2015-07-28T12:24:16Z")

</div>

Some help please,  
I know than I have to use debug\_output\_ function in order to get debug messages at run time.  
What I do not find is where I have to turn on debugging.

---

<div class="post-metadata">

**Author:** ![ielec](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ielec/32/7437_2.png) [@ielec](https://community.particle.io/u/ielec)\
**Post date:** [July 29, 2015, 9:41am UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/2 "2015-07-29T09:41:15Z")

</div>

I’m also looking for the answer to this question. I found the function  
`void set_logger_output(debug_output_fn output, LoggerOutputLevel level)`  
will implement the  
`debug_output_`  
function. But after looking into the source code and libraries, the  
`set_logger_output`  
doesn’t been invoked by anywhere.

So regarding to Photon, how to implement debug print:  
`DEBUG("Hello from Spark!");`  
in the function  
`app_setup_and_loop()`

---

<div class="post-metadata">

**Author:** ![yianmar](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/yianmar/32/2990_2.png) [@yianmar](https://community.particle.io/u/yianmar)\
**Post date:** [July 30, 2015, 4:07pm UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/3 "2015-07-30T16:07:33Z")

</div>

I just remeber from core that it was easy by ,somehow, setting DEBUG mode to something , but I do not remenber more

---

<div class="post-metadata">

**Author:** ![yianmar](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/yianmar/32/2990_2.png) [@yianmar](https://community.particle.io/u/yianmar)\
**Post date:** [July 30, 2015, 8:04pm UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/4 "2015-07-30T20:04:15Z")

</div>

```
static bool log = false;
void debug_output_(const char *p)
{
    if (log)
        Serial.println(p);
}

```

And then in setup()

Serial.begin(57600);  
log = true;

---

<div class="post-metadata">

**Author:** ![yianmar](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/yianmar/32/2990_2.png) [@yianmar](https://community.particle.io/u/yianmar)\
**Post date:** [July 30, 2015, 8:21pm UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/5 "2015-07-30T20:21:55Z")

</div>

That is what found, but it does not work to me.

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [August 20, 2015, 4:51am UTC](https://community.particle.io/t/debugging-run-time-on-off-at-source-firmware-code-for-photon/13882/6 "2015-08-20T04:51:27Z")

</div>

Debugging docs here - [https://github.com/spark/firmware/blob/develop/docs/debugging.md](https://github.com/spark/firmware/blob/develop/docs/debugging.md)
