Changeset dce72c1
- 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)
- Location:
- perl/lib/BarnOwl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Logging.pm
r03fbf66 rdce72c1 89 89 . "is selected both incoming and outgoing messages are\n" 90 90 . "logged." 91 }); 92 93 BarnOwl::new_variable_string('logbasepath', 94 { 95 default => '~/zlog', 96 validsettings => '<path>', 97 summary => 'path for logging non-zephyr messages', 98 description => "Specifies a directory which must exist.\n" 99 . "Each non-zephyr protocol gets its own subdirectory in\n" 100 . "logbasepath, and messages get logged there." 91 101 }); 92 102 … … 141 151 This method calls C<log_filenames> on C<MESSAGE> to determine the list 142 152 of filenames to which C<MESSAGE> gets logged. All filenames are 143 relative to C<MESSAGE->log_ base_path>. If C<MESSAGE->log_to_all_file>153 relative to C<MESSAGE->log_path>. If C<MESSAGE->log_to_all_file> 144 154 returns true, then the filename C<"all"> is appended to the list of 145 155 filenames. … … 153 163 my @filenames = $m->log_filenames; 154 164 push @filenames, 'all' if $m->log_to_all_file; 155 return map { sanitize_filename($m->log_ base_path, $_) } @filenames;165 return map { sanitize_filename($m->log_path, $_) } @filenames; 156 166 } 157 167 -
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 -
perl/lib/BarnOwl/Message/Zephyr.pm
r3374de9 rdce72c1 274 274 } 275 275 276 sub log_ base_path {276 sub log_path { 277 277 my ($m) = @_; 278 278 if ($m->log_to_class_file) {
Note: See TracChangeset
for help on using the changeset viewer.