1 # File: Stem/Log/Entry.pm
3 # This file is part of Stem.
4 # Copyright (C) 1999, 2000, 2001 Stem Systems, Inc.
6 # Stem is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # Stem is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Stem; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # For a license to use the Stem under conditions other than those
21 # described here, to purchase support for this software, or to purchase a
22 # commercial warranty contract, please contact Stem Systems at:
24 # Stem Systems, Inc. 781-643-7504
25 # 79 Everett St. info@stemsystems.com
33 package Stem::Log::Entry ;
35 Stem::Route::register_class( __PACKAGE__, 'entry' ) ;
44 Text for this log entry. Can be filtered with the rule 'match_text'.
51 Label for this log entry. This is used to tag log entries from
52 different sources. Can be filtered with the rule 'match_label'.
59 Severity level for this log entry. It is an integer with 0 being the
60 most severe level and 10 the lowest (this maps to the levels of
61 syslog). There are several rules which can filter based on the level.
68 This is a list of logical logs where this entry is submitted. The
69 first one is considered the original log. If this is not passed, then
70 the entry must be explicitly submitted by the submit method.
79 my( $class ) = shift ;
81 my $self = Stem::Class::parse_args( $attr_spec, @_ ) ;
82 return $self unless ref $self ;
84 $self->{'time'} = time() ;
85 $self->{'hub_name'} = $Stem::Vars::Hub_name ;
86 $self->{'host_name'} = $Stem::Vars::Host_name ;
87 $self->{'program_name'} = $Stem::Vars::Program_name ;
89 if ( my $logs_attr = $self->{'logs'} ) {
91 $self->submit( @{$logs_attr} ) ;
99 my( $self, @logs ) = @_ ;
101 foreach my $log_name ( @logs ) {
103 #print "LOG [$log_name]\n" ;
104 if ( $log_name =~ /^(\w+):(\w+)$/ ) {
109 my $log_msg = Stem::Msg->new(
110 'to' => "$to_hub:" . __PACKAGE__,
111 'from' => __PACKAGE__,
117 #print $log_msg->dump( 'LOG out' ) ;
120 $log_msg->dispatch() ;
125 my $log_obj = Stem::Log::find_log( $log_name ) ;
127 next unless $log_obj ;
130 my $entry_copy ||= { %{$self} } ;
132 $entry_copy->{'log_name'} = $log_name ;
133 $entry_copy->{'orig_log_name'} ||= $log_name ;
134 $entry_copy->{'entry_obj'} = $self ;
136 $log_obj->submit( $entry_copy ) ;
140 # this method is how a remote log message is delivered locally
144 my( $class, $msg ) = @_ ;
146 my $entry = $msg->data() ;
148 print "$entry\n" unless ref $entry ;
150 #print $msg->dump( 'LOG in' ) ;
152 $entry->submit( $msg->log() ) ;