I
Iñaki Baz Castillo
Hi, by redirecting $stderr to a logger (Logger or SyslogLogger instance) I'=
ve=20
realized that Kernel#warn prints an extra \n so the logger is called twice=
=20
(the second one with an empty line).
The "warn" code shows it clearly:
static VALUE
rb_warn_m(self, mesg)
VALUE self, mesg;
{
if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg);
rb_io_write(rb_stderr, rb_default_rs);
}
return Qnil;
}
So for example by redirecting $stderr to a Logger instance
warn "hello"
I get:
# Logfile created on 2010-01-04 21:32:21 +0100 by logger.rb/20321
F, [2010-01-04T21:32:38.981099 #22370] FATAL -- : hello
F, [2010-01-04T21:32:38.981385 #22370] FATAL -- :
Can this be avoided (without rewritting "warn" call)? Thanks.
=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
ve=20
realized that Kernel#warn prints an extra \n so the logger is called twice=
=20
(the second one with an empty line).
The "warn" code shows it clearly:
static VALUE
rb_warn_m(self, mesg)
VALUE self, mesg;
{
if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg);
rb_io_write(rb_stderr, rb_default_rs);
}
return Qnil;
}
So for example by redirecting $stderr to a Logger instance
warn "hello"
I get:
# Logfile created on 2010-01-04 21:32:21 +0100 by logger.rb/20321
F, [2010-01-04T21:32:38.981099 #22370] FATAL -- : hello
F, [2010-01-04T21:32:38.981385 #22370] FATAL -- :
Can this be avoided (without rewritting "warn" call)? Thanks.
=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>