print statement redirection

Hi,
I am trying to locate how the “print” and “print fmt” statements work in bro scripts ; where are they implemented in source ? Specifically I am trying to determine if they always use stdout and stderr as inherited by src/main.cc

Any suggestions welcome !

Is this sort of what you’re looking for?

global my_file = open(“test.txt”);
event bro_init()
  {
  print my_file, “woo!”;
  }

  .Seth

That is interesting , but it doesn’t really satisfy my curiosity Does the scripting I/O not use stderr + stdout ? I am interested in getting bro to redirect to syslog by inheriting file descriptors on startup .

Ah, ok. I didn’t understand where you are trying to get to in the end. It does use stdout if you don’t send the content off to a certain location. I take it that you have a script you’ve written that prints? I’m asking since Bro doesn’t print much to stdout or stderr by default I don’t immediately see the utility of redirecting those to syslog.

The implementation for the print statement can be found in Stmt.cc around line 259.

  .Seth

That is interesting , but it doesn't really satisfy my curiosity Does the
scripting I/O not use stderr + stdout ?

By default, print does go to stdout. The code is in src/Stmt.cc,
PrintStmt::DoExec().

I am interested in getting bro to redirect to syslog by inheriting
file descriptors on startup .

Just to be sure, you know there's a builtin function syslog(msg),
right?

Robin