Changeset 5dee79a for perl


Ignore:
Timestamp:
Aug 16, 2017, 12:53:41 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
8cec8f7
Parents:
d2ba33c
git-author:
Jason Gross <jgross@mit.edu> (01/05/14 18:08:28)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
Message:
Add log-to-subdirectories, a compatibility frob

If disabled (the default), then logging of jabber and AIM messages
behaves how it used to.  If enabled, then each protocol gets its own
subdirectory.
Location:
perl/lib/BarnOwl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Logging.pm

    r6ddfb07 r5dee79a  
    120120                           . "Files will be created in the directory for each class."
    121121        });
     122
     123    BarnOwl::new_variable_bool('log-to-subdirectories',
     124        {
     125            default     => 0,
     126            summary     => "log each protocol to its own subdirectory of logbasepath",
     127            description => "When this is enabled, BarnOwl will log each protocol to its own\n"
     128                         . "subdirectory of logbasepath.  When this is disabled, BarnOwl will\n"
     129                         . "instead log all non-zephyr non-loopback messages to the logpath,\n"
     130                         . "and prefix each filename with what would otherwise be the subdirectory\n"
     131                         . "name.\n\n"
     132                         . "If you enable this, be sure that the relevant directories exist;\n"
     133                         . "BarnOwl will not create them for you."
     134        });
     135
    122136}
    123137
  • perl/lib/BarnOwl/Message.pm

    rdce72c1 r5dee79a  
    183183    }
    184184    $filename = "unknown" if !defined($filename) || $filename eq '';
    185     return ($filename);
     185    if (BarnOwl::getvar('log-to-subdirectories') eq 'on') {
     186        return ($filename);
     187    } else {
     188        return ($m->log_subfolder . ':' . $filename);
     189    }
    186190}
    187191
     
    205209Returns the folder in which all messages of this class get logged.
    206210
    207 Defaults to C<log_base_path>/C<log_subfolder>.
     211Defaults to C<log_base_path/log_subfolder> if C<log-to-subdirectories>
     212is enabled, or to the C<logpath> BarnOwl variable if it is not.
     213
     214Most protocols should override C<log_subfolder> rather than
     215C<log_path>, in order to properly take into account the value of
     216C<log-to-subdirectories>.
    208217
    209218=cut
     
    211220sub log_path {
    212221    my ($m) = @_;
    213     return File::Spec->catfile($m->log_base_path, $m->log_subfolder);
     222    if (BarnOwl::getvar('log-to-subdirectories') eq 'on') {
     223        return File::Spec->catfile($m->log_base_path, $m->log_subfolder);
     224    } else {
     225        return BarnOwl::getvar('logpath');
     226    }
    214227}
    215228
Note: See TracChangeset for help on using the changeset viewer.