freopen action changes the file associated with stdout to the file specified by pathname argument. This action is potentially destructive and needs to be activated via –w or destructive option.
"dispatch_command": #!/usr/sbin/dtrace -qw #pragma D option strsize=1024 dtrace:::BEGIN { freopen("/tmp/sqls"); } pid$target::*dispatch_command*:entry { printf("%Y-> %s \n",walltimestamp,copyinstr(arg2)); }
which gives logs like:
2009 Feb 5 08:13:43- > create table fo_bawr (i INTEGER) 2009 Feb 5 08:13:56- > create table foo_bar (is INTEGER)