cvs commit: p5ee/App-Context/lib/App Context.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     06/02/24 14:28:40

  Modified:    App-Context/lib/App Context.pm
  Log:
  added log levels (and optional args to log())
  
  Revision  Changes    Path
  1.25      +17 -1     p5ee/App-Context/lib/App/Context.pm
  
  Index: Context.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App/Context.pm,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Context.pm	18 Jan 2006 14:55:58 -0000	1.24
  +++ Context.pm	24 Feb 2006 22:28:40 -0000	1.25
  @@ -1268,6 +1268,9 @@
   the default log channel.
   
       * Signature: $context->log(@args);
  +    * Signature: $context->log($options, @args);
  +    * Param:  $options     HASH    [in] (named)
  +    * Param:  log_level    integer
       * Param:  @args        string  [in]
       * Return: void
       * Throws: <none>
  @@ -1282,6 +1285,19 @@
   sub log {
       &App::sub_entry if ($App::trace);
       my $self = shift;
  +    my ($msg_options);
  +    $msg_options = shift if ($#_ > -1 && ref($_[0]) eq "HASH");
  +    my $msg_log_level = $msg_options->{log_level} || 1;
  +    my $log_level = $self->{options}{log_level};
  +    if (!defined $log_level || $msg_log_level <= $log_level) {
  +        $self->_log(@_);
  +    }
  +    &App::sub_exit() if ($App::trace);
  +}
  +
  +sub _log {
  +    &App::sub_entry if ($App::trace);
  +    my $self = shift;
       print STDERR "[$$] ", time2str("%Y-%m-%d %H:%M:%S", time()), " ", @_;
       &App::sub_exit() if ($App::trace);
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.