Observing what Spotlight's mdworker is indexing for diagnostic purposes

I’m not sure whether there’s a more detailed log generated by mdworker or mds themselves. You could use fs_usage to see what files they are reading though, run the following in Terminal:

sudo fs_usage mdworker mds

As it says in the man page: “The fs_usage utility presents an ongoing display of system call usage information pertaining to filesystem activity. It requires root privileges due to the kernel tracing facility it uses to operate. By default, the activity monitored includes all system processes except […]. These defaults can be overridden such that output is limited to include or exclude a list of processes specified by the user.”

Here’s a short sample of the output you'll get (I ran this in a narrow window, use a wider one to get the file paths in more detail):

11:07:49  fsgetpath         resourceLog.plist    0.000029   mds         
11:07:49  getattrlist       resourceLog.plist    0.000089   mds         
11:07:49  listxattr         resourceLog.plist    0.000042   mds         
11:07:49  getattrlist       resourceLog.plist    0.000164   mds         
11:07:49  getattrlist       resourceLog.plist    0.000029   mds         
11:07:54  exit                                   0.000118   mdworker    

The exit calls correspond to the messages “Service exited due to signal” in the “system.log”:

Aug  8 11:07:54 […] com.apple.xpc.launchd[1] (com.apple.mdworker.single.[…]):
  Service exited due to signal: Killed: 9 sent by mds[114]

For some more information on fs_usage, there’s an (old) article on ‘macobserver.com’ titled “Mac OS X: Using fs_usage as a Troubleshooting Tool”.