EarthScope / slinktool

Other
18 stars 15 forks source link

Managing slinktool's stdout and stderr #8

Closed jschaeff closed 4 years ago

jschaeff commented 4 years ago

Hi, I'd like to pipe the output of slinktool (stdout and stderr) into syslog, but I don't get all the messages.

I only get messages logged with the function sl_log_r (slconn, ...) but not the messages logged with the finction sl_log(...).

The documentation is clear about the mesage level and verbosity level, still, I miss the logs like "Createing directory ..." from src/dsarchive.c: when piping slinktool's output.

To reproduce: Whith this command I can see the "Creating directory ..." line

rm -rf 2020 && ./slinktool -v -S FR_ILLK -SDS . rtserve.resif.fr:18000 2>&1

With this command, they are not getting piped, I loose them:

rm -rf 2020 && ./slinktool -v -S FR_ILLK -SDS . rtserve.resif.fr:18000 2>&1 |grep ""

What do I want to accomplish ? I'd like to add a log on data stream file creation, capture it as an event to do stuff. I added this line:

modified: src/dsarchive.c
────────────────────────────────────────────
@ src/dsarchive.c:402 @ ds_getstream (DataStream **streamroot, const SLMSrecord *msr,
      sl_log (1, 0, "opening new data stream file, %s\n", strerror (errno));
      return NULL;
    }
    sl_log (0, 0, "New data stream file created: %s\n", filename);

    setvbuf (foundstream->filep, NULL, _IONBF, 0);
  }

I can see the log when running slinktool, but it disapears when I pipe it out.

jschaeff commented 4 years ago
stdbuf -o0 ./slinktool -v -S FR_ILLK -SDS . rtserve.resif.fr:18000 2>&1 |grep ""

works.

For my need, it's just enough.