Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think such filtering is possible out of the box. But it's possible to redirect <code>stderr</code> (which is used by <code>NSLog</code>) into a pipe, read from that pipe in a background thread and then print messages that pass through the filter onto <code>stdout</code> (which is captured by the debugger as well). This code does the job:</p> <pre><code>int main(int argc, char *argv[]) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) { size_t const BUFFER_SIZE = 2048; // Create a pipe int pipe_in_out[2]; if (pipe(pipe_in_out) == -1) return; // Connect the 'in' end of the pipe to the stderr if (dup2(pipe_in_out[1], STDERR_FILENO) == -1) return; char *buffer = malloc(BUFFER_SIZE); if (buffer == 0) return; for (;;) { // Read from the 'out' end of the pipe ssize_t bytes_read = read(pipe_in_out[0], buffer, BUFFER_SIZE); if (bytes_read &lt;= 0) break; // Filter and print to stdout if (should_show(buffer)) // TODO: Apply filters here fwrite(buffer, 1, bytes_read, stdout); } free(buffer); close(pipe_in_out[1]); }); // Rest of main } </code></pre> <p>Please note that this code is quite simple and doesn't handle all corner cases. First of all it captures all <code>stderr</code> output and not just <code>NSLog</code>. Maybe this could be filtered out by checking against the content. <code>NSLog</code> output always starts with the date and time.</p> <p>Second problem with this code is that it doesn't try to split/join strings it reads from the pipe. There's no guarantee that there will be one <code>NSLog</code> per read. They could be coming together or be too long and would be split. To handle this it would require additional processing of the data read from the pipe.</p> <p>Anyway, for many practical purposes this should be enough.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload