[4112] in BarnOwl Developers
Re: [barnowl/barnowl] Perl logging (#54)
daemon@ATHENA.MIT.EDU (Alex Dehnert)
Sun Aug 6 01:11:12 2017
Date: Sun, 06 Aug 2017 05:11:06 +0000 (UTC)
From: Alex Dehnert <notifications@github.com>
Reply-To: barnowl/barnowl <reply+004448c980fa762148a9b4f9494329ccd7460fc1229b0a3b92cf00000001159e66e992a169ce00127fe9@reply.github.com>
To: barnowl/barnowl <barnowl@noreply.github.com>
Cc: barnowl-dev email-only account <barnowl-dev@mit.edu>,
Comment <comment@noreply.github.com>
In-Reply-To: <barnowl/barnowl/pull/54@github.com>
----==_mimepart_5986a4e9ee4dd_e703fc3115e3c38104142
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
adehnert commented on this pull request.
> + description => "If this is set to on, class messages are\n"
+ . "logged in the directory specified by the\n"
+ . "'classpath' variable. The filename in that\n"
+ . "directory is derived from the class to which\n"
+ . "the message was sent."
+ });
+
+ BarnOwl::new_variable_string('logfilter',
+ {
+ default => '',
+ summary => 'name of a filter controlling which messages to log',
+ description => "If non empty, any messages matching the given filter will be logged.\n"
+ . "This is a completely separate mechanism from the other logging\n"
+ . "variables like logging, classlogging, loglogins, loggingdirection,\n"
+ . "etc. If you want this variable to control all logging, make sure\n"
+ . "all other logging variables are in their default state."
"default state" seems like a dubious phrase -- "are left off (the default)" might be better.
> + {
+ default => '',
+ summary => 'name of a filter controlling which messages to log',
+ description => "If non empty, any messages matching the given filter will be logged.\n"
+ . "This is a completely separate mechanism from the other logging\n"
+ . "variables like logging, classlogging, loglogins, loggingdirection,\n"
+ . "etc. If you want this variable to control all logging, make sure\n"
+ . "all other logging variables are in their default state."
+ });
+
+ BarnOwl::new_variable_bool('loglogins',
+ {
+ default => 0,
+ summary => 'enable logging of login notifications',
+ description => "When this is enabled, BarnOwl will log login and logout notifications\n"
+ . "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n"
"log"? "print"? Should that be "log" too?
> + });
+
+ BarnOwl::new_variable_enum('loggingdirection',
+ {
+ default => 'both',
+ validsettings => [qw(in out both)],
+ summary => "specifies which kind of messages should be logged",
+ description => "Can be one of 'both', 'in', or 'out'. If 'in' is\n"
+ . "selected, only incoming messages are logged, if 'out'\n"
+ . "is selected only outgoing messages are logged. If 'both'\n"
+ . "is selected both incoming and outgoing messages are\n"
+ . "logged.\n\n"
+ . "Note that this variable applies to all messages. In\n"
+ . "particular, if this variable is set to 'out', the\n"
+ . "classlogging variable will have no effect, and no\n"
+ . "class messages will be logged."
Perhaps change to "and no class messages (which are always incoming) will be logged"?
> +Sanitizes C<FILENAME> and concatenates it with C<BASE_PATH>.
+
+In any filename, C<"/"> and any control characters (characters which
+match C<[:cntrl:]> get replaced by underscores. If the resulting
+filename is empty or equal to C<"."> or C<"..">, it is replaced with
+C<"weird">.
+
+=cut
+
+sub sanitize_filename {
+ my $base_path = BarnOwl::Internal::makepath(shift);
+ my $filename = shift;
+ $filename =~ s/[[:cntrl:]\/]/_/g;
+ if ($filename eq '' || $filename eq '.' || $filename eq '..') {
+ $filename = 'weird';
+ }
I don't think hidden files of logging are good (and, eg, creating .gitconfig seems bad, and .git maybe worse). Can you change this to consider anything starting a dot to be weird, please?
> + return $m->log_header . "\n\n" . $m->log_body . "\n\n";
+}
+
+=head2 log_header MESSAGE
+
+Returns the header of the message, for logging purposes.
+If you override L<BarnOwl::Message::log>, this method is not called.
+
+=cut
+
+sub log_header {
+ my ($m) = @_;
+ my $sender = $m->sender;
+ my $recipient = $m->recipient;
+ my $timestr = $m->time;
+ return "From: <$sender> To: <$recipient>\n"
Should From and To be on different lines?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/barnowl/barnowl/pull/54#pullrequestreview-54526702
----==_mimepart_5986a4e9ee4dd_e703fc3115e3c38104142
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p><b>@adehnert</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/barnowl/barnowl/pull/54#discussion_r131533827">perl/lib/BarnOwl/Logging.pm</a>:</p>
<pre style='color:#555'>> + description => "If this is set to on, class messages are\n"
+ . "logged in the directory specified by the\n"
+ . "'classpath' variable. The filename in that\n"
+ . "directory is derived from the class to which\n"
+ . "the message was sent."
+ });
+
+ BarnOwl::new_variable_string('logfilter',
+ {
+ default => '',
+ summary => 'name of a filter controlling which messages to log',
+ description => "If non empty, any messages matching the given filter will be logged.\n"
+ . "This is a completely separate mechanism from the other logging\n"
+ . "variables like logging, classlogging, loglogins, loggingdirection,\n"
+ . "etc. If you want this variable to control all logging, make sure\n"
+ . "all other logging variables are in their default state."
</pre>
<p>"default state" seems like a dubious phrase -- "are left off (the default)" might be better.</p>
<hr>
<p>In <a href="https://github.com/barnowl/barnowl/pull/54#discussion_r131533833">perl/lib/BarnOwl/Logging.pm</a>:</p>
<pre style='color:#555'>> + {
+ default => '',
+ summary => 'name of a filter controlling which messages to log',
+ description => "If non empty, any messages matching the given filter will be logged.\n"
+ . "This is a completely separate mechanism from the other logging\n"
+ . "variables like logging, classlogging, loglogins, loggingdirection,\n"
+ . "etc. If you want this variable to control all logging, make sure\n"
+ . "all other logging variables are in their default state."
+ });
+
+ BarnOwl::new_variable_bool('loglogins',
+ {
+ default => 0,
+ summary => 'enable logging of login notifications',
+ description => "When this is enabled, BarnOwl will log login and logout notifications\n"
+ . "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n"
</pre>
<p>"log"? "print"? Should that be "log" too?</p>
<hr>
<p>In <a href="https://github.com/barnowl/barnowl/pull/54#discussion_r131533885">perl/lib/BarnOwl/Logging.pm</a>:</p>
<pre style='color:#555'>> + });
+
+ BarnOwl::new_variable_enum('loggingdirection',
+ {
+ default => 'both',
+ validsettings => [qw(in out both)],
+ summary => "specifies which kind of messages should be logged",
+ description => "Can be one of 'both', 'in', or 'out'. If 'in' is\n"
+ . "selected, only incoming messages are logged, if 'out'\n"
+ . "is selected only outgoing messages are logged. If 'both'\n"
+ . "is selected both incoming and outgoing messages are\n"
+ . "logged.\n\n"
+ . "Note that this variable applies to all messages. In\n"
+ . "particular, if this variable is set to 'out', the\n"
+ . "classlogging variable will have no effect, and no\n"
+ . "class messages will be logged."
</pre>
<p>Perhaps change to "and no class messages (which are always incoming) will be logged"?</p>
<hr>
<p>In <a href="https://github.com/barnowl/barnowl/pull/54#discussion_r131534022">perl/lib/BarnOwl/Logging.pm</a>:</p>
<pre style='color:#555'>> +Sanitizes C<FILENAME> and concatenates it with C<BASE_PATH>.
+
+In any filename, C<"/"> and any control characters (characters which
+match C<[:cntrl:]> get replaced by underscores. If the resulting
+filename is empty or equal to C<"."> or C<"..">, it is replaced with
+C<"weird">.
+
+=cut
+
+sub sanitize_filename {
+ my $base_path = BarnOwl::Internal::makepath(shift);
+ my $filename = shift;
+ $filename =~ s/[[:cntrl:]\/]/_/g;
+ if ($filename eq '' || $filename eq '.' || $filename eq '..') {
+ $filename = 'weird';
+ }
</pre>
<p>I don't think hidden files of logging are good (and, eg, creating .gitconfig seems bad, and .git maybe worse). Can you change this to consider anything starting a dot to be weird, please?</p>
<hr>
<p>In <a href="https://github.com/barnowl/barnowl/pull/54#discussion_r131534436">perl/lib/BarnOwl/Message.pm</a>:</p>
<pre style='color:#555'>> + return $m->log_header . "\n\n" . $m->log_body . "\n\n";
+}
+
+=head2 log_header MESSAGE
+
+Returns the header of the message, for logging purposes.
+If you override L<BarnOwl::Message::log>, this method is not called.
+
+=cut
+
+sub log_header {
+ my ($m) = @_;
+ my $sender = $m->sender;
+ my $recipient = $m->recipient;
+ my $timestr = $m->time;
+ return "From: <$sender> To: <$recipient>\n"
</pre>
<p>Should From and To be on different lines?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you commented.<br />Reply to this email directly, <a href="https://github.com/barnowl/barnowl/pull/54#pullrequestreview-54526702">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AERIyfa9vLcqgPQIiioAUq8R05R5TGXJks5sVUrpgaJpZM4BW8Zd">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AERIyWSKGzdpNVyUV1fAuScEBlUobIQWks5sVUrpgaJpZM4BW8Zd.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/barnowl/barnowl/pull/54#pullrequestreview-54526702"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/barnowl/barnowl","title":"barnowl/barnowl","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/barnowl/barnowl"}},"updates":{"snippets":[{"icon":"PERSON","message":"@adehnert commented on #54"}],"action":{"name":"View Pull Request","url":"https://github.com/barnowl/barnowl/pull/54#pullrequestreview-54526702"}}}</script>
----==_mimepart_5986a4e9ee4dd_e703fc3115e3c38104142--