There's a fair bit of logging in TouchDB that can be enabled for troubleshooting purposes. Serious/unexpected problems will always be logged with a message starting "WARNING:", but less serious logs need to be enabled using user-defaults or command-line arguments.
TouchDB uses the logging API from my MYUtilities library. There's a
Log(@"...") function that's used just like
NSLog. It produces no output by default, but there's a master switch to turn it on (the boolean user default also called
Beyond that, the
LogTo(Channel, @"...") function will log to an arbitrary named "channel". Channels are off by default but are individually enabled by user defaults, so for instance the default
LogFoo turns on the
Foo channel. (But only if the master log switch is enabled too.)
You can turn these flags on programmatically with the
NSUserDefaults class, or persistently from the command-line using the
defaults tool (using your app's bundle ID, of course), but during development the most convenient way is to set them from Xcode's scheme editor. This lets you toggle them with GUI checkboxes. Here's how:
This adds two command-line arguments when Xcode launches your app. NSUserDefaults parses these at launch time and temporarily sets the value of
true.) This is persistent as long as you run your app from Xcode, but it's not stored in the system/device user defaults so it has no effect on launching your app normally. Moreover, you can easily turn it off using the checkbox next to its list item.
Enabling "channels" works the same way. Add another argument item whose value is e.g.
-LogFoo YES to turn on channel
Foo. (Remember that you also need to have the
-Log YES item enabled or no logs will appear at all.)
Most of TouchDB's logging goes to specific channels. Here are some useful ones to turn on:
Last edited by Jens Alfke,