my $act_logfile_enabled = 1;# are we logging to a file?
my $max_log_msg_len = 1536; # SYSLOG default maximum is 2048
+# force stdout logging; useful when not connecting to opensrf
+my $log_stdout = 0;
+
our $logger = "OpenSRF::Utils::Logger";
# log levels
my $isclient; # true if we control the osrf_xid
+sub set_log_level {
+ my ($self, $level) = @_;
+ $loglevel = $level;
+}
+
+sub set_log_stdout {
+ my ($eslf, $value) = @_;
+ $log_stdout = $value;
+}
+
# load up our config options
sub set_config {
my $force = shift;
- return if defined $config and !$force;
+ return if (defined $config || $log_stdout) and !$force;
$config = OpenSRF::Utils::Config->current;
if( !defined($config) ) {
$loglevel = INFO();
- warn "*** Logger found no config. Using STDERR ***\n";
return;
}
if ($file) {
sysopen( SINK, $file, O_NONBLOCK|O_WRONLY|O_APPEND|O_CREAT )
or die "Cannot sysopen $file: $!";
+ } elsif ($log_stdout) {
+ open (SINK, ">&1"); # print to STDOUT
} else {
open (SINK, ">&2"); # print to STDERR as warned
}