Changeset dce72c1 for perl/lib/BarnOwl/Message.pm
- Timestamp:
- Aug 16, 2017, 12:53:41 PM (7 years ago)
- Branches:
- master
- Children:
- 15b87cc
- Parents:
- 9a34040
- git-author:
- Jason Gross <jgross@mit.edu> (02/16/13 23:46:21)
- git-committer:
- Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Message.pm
r5093c6f rdce72c1 3 3 4 4 package BarnOwl::Message; 5 6 use File::Spec; 5 7 6 8 use BarnOwl::Message::Admin; … … 165 167 166 168 Returns a list of filenames to which this message should be logged. 167 The filenames should be relative to the path returned by 168 C<log_base_path>. See L<BarnOwl::Logging::get_filenames> for the 169 specification of valid filenames, and for what happens if this 170 method returns an invalidfilename.169 The filenames should be relative to the path returned by C<log_path>. 170 See L<BarnOwl::Logging::get_filenames> for the specification of valid 171 filenames, and for what happens if this method returns an invalid 172 filename. 171 173 172 174 =cut … … 174 176 sub log_filenames { 175 177 my ($m) = @_; 176 my $filename = lc($m->type);177 $filename = "unknown" if !defined $filename || $filename eq '';178 if ($m->is_incoming && $m->pretty_sender) {179 $filename .= ":" . $m->pretty_sender;180 } elsif ($m->is_outgoing && $m->pretty_recipient) {181 $filename .= ":" . $m->pretty_recipient;182 }178 my $filename; 179 if ($m->is_incoming) { 180 $filename = $m->pretty_sender; 181 } elsif ($m->is_outgoing) { 182 $filename = $m->pretty_recipient; 183 } 184 $filename = "unknown" if !defined($filename) || $filename eq ''; 183 185 return ($filename); 184 186 } … … 199 201 } 200 202 203 =head2 log_path MESSAGE 204 205 Returns the folder in which all messages of this class get logged. 206 207 Defaults to C<log_base_path>/C<log_subfolder>. 208 209 =cut 210 211 sub log_path { 212 my ($m) = @_; 213 return File::Spec->catfile($m->log_base_path, $m->log_subfolder); 214 } 215 201 216 =head2 log_base_path MESSAGE 202 217 203 Returns the base path for logging, the folder in which all messages 204 of this class get logged. 205 206 Defaults to the BarnOwl variable C<logpath>. 218 Returns the base path for logging. See C<log_path> for more information. 219 220 Defaults to the BarnOwl variable C<logbasepath>. 207 221 208 222 =cut 209 223 210 224 sub log_base_path { 211 return BarnOwl::getvar('logpath'); 225 return BarnOwl::getvar('logbasepath'); 226 } 227 228 =head2 log_subfolder MESSAGE 229 230 Returns the subfolder of C<log_base_path> to log messages in. 231 232 Defaults to C<lc($m->type)>. 233 234 =cut 235 236 sub log_subfolder { 237 return lc(shift->type); 212 238 } 213 239
Note: See TracChangeset
for help on using the changeset viewer.