# Dispatch (swift-corelibs-libdispatch) Debug Logging

**URL:** <https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567>\
**Category:** Core Libraries\
**Tags:** linux, dispatch\
**Created:** [May 11, 2018, 2:35am UTC](https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567 "2018-05-11T02:35:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlovelett](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rlovelett/32/753_2.png) [@rlovelett](https://forums.swift.org/u/rlovelett)\
**Post date:** [May 11, 2018, 2:35am UTC](https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567/1 "2018-05-11T02:35:51Z")

</div>

I am trying to debug Dispatch to see [what is causing a bug I've stumbled into](https://forums.swift.org/t/pipe-child-processes-together/12527/3).

I've actually got a debug build of libdispatch made and am able to step through it with `lldb` 🎉 .

I was wondering how I go about enabling [some of the logging](https://github.com/apple/swift-corelibs-libdispatch/blob/a618b468b94ad6abb14a19af76e33018700af6bc/src/io.c#L154-L163) in libdispatch.

I'm not sure what or how I would send to the Swift `build-script` to get that part of the compilation turned on.

---

<div class="post-metadata">

**Author:** ![rlovelett](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rlovelett/32/753_2.png) [@rlovelett](https://forums.swift.org/u/rlovelett)\
**Post date:** [May 11, 2018, 1:26pm UTC](https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567/2 "2018-05-11T13:26:45Z")

</div>

I've added `libdispatch-cmake-options=-DDISPATCH_ENABLE_ASSERTS=1 -DDISPATCH_DEBUG=1 -DDISPATCH_IO_DEBUG=1` to my `.swift-build-presets` and I see it showing up the arguments sent to the libdispatch compiler. Though I'm still not seeing any logs actually being written.

---

<div class="post-metadata">

**Author:** ![dgrove-oss](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dgrove-oss](https://forums.swift.org/u/dgrove-oss)\
**Post date:** [May 11, 2018, 2:22pm UTC](https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567/3 "2018-05-11T14:22:19Z")

</div>

I think you need to set LIBDISPATCH\_LOG in your environment when you are running the program as well.

> <https://github.com/apple/swift-corelibs-libdispatch/blob/a618b468b94ad6abb14a19af76e33018700af6bc/src/init.c#L687-%23L705>

---

<div class="post-metadata">

**Author:** ![rlovelett](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rlovelett/32/753_2.png) [@rlovelett](https://forums.swift.org/u/rlovelett)\
**Post date:** [May 11, 2018, 2:53pm UTC](https://forums.swift.org/t/dispatch-swift-corelibs-libdispatch-debug-logging/12567/4 "2018-05-11T14:53:51Z")

</div>

🎉

`LIBDISPATCH_LOG=stderr ./test`

Thank you @dgrove-oss
