[4112] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

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'>&gt; +            description =&gt; &quot;If this is set to on, class messages are\n&quot;
+                         . &quot;logged in the directory specified by the\n&quot;
+                         . &quot;&#39;classpath&#39; variable.  The filename in that\n&quot;
+                         . &quot;directory is derived from the class to which\n&quot;
+                         . &quot;the message was sent.&quot;
+        });
+
+    BarnOwl::new_variable_string(&#39;logfilter&#39;,
+        {
+            default     =&gt; &#39;&#39;,
+            summary     =&gt; &#39;name of a filter controlling which messages to log&#39;,
+            description =&gt; &quot;If non empty, any messages matching the given filter will be logged.\n&quot;
+                         . &quot;This is a completely separate mechanism from the other logging\n&quot;
+                         . &quot;variables like logging, classlogging, loglogins, loggingdirection,\n&quot;
+                         . &quot;etc.  If you want this variable to control all logging, make sure\n&quot;
+                         . &quot;all other logging variables are in their default state.&quot;
</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'>&gt; +        {
+            default     =&gt; &#39;&#39;,
+            summary     =&gt; &#39;name of a filter controlling which messages to log&#39;,
+            description =&gt; &quot;If non empty, any messages matching the given filter will be logged.\n&quot;
+                         . &quot;This is a completely separate mechanism from the other logging\n&quot;
+                         . &quot;variables like logging, classlogging, loglogins, loggingdirection,\n&quot;
+                         . &quot;etc.  If you want this variable to control all logging, make sure\n&quot;
+                         . &quot;all other logging variables are in their default state.&quot;
+        });
+
+    BarnOwl::new_variable_bool(&#39;loglogins&#39;,
+        {
+            default     =&gt; 0,
+            summary     =&gt; &#39;enable logging of login notifications&#39;,
+            description =&gt; &quot;When this is enabled, BarnOwl will log login and logout notifications\n&quot;
+                         . &quot;for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n&quot;
</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'>&gt; +        });
+
+    BarnOwl::new_variable_enum(&#39;loggingdirection&#39;,
+        {
+            default       =&gt; &#39;both&#39;,
+            validsettings =&gt; [qw(in out both)],
+            summary       =&gt; &quot;specifies which kind of messages should be logged&quot;,
+            description   =&gt; &quot;Can be one of &#39;both&#39;, &#39;in&#39;, or &#39;out&#39;.  If &#39;in&#39; is\n&quot;
+                           . &quot;selected, only incoming messages are logged, if &#39;out&#39;\n&quot;
+                           . &quot;is selected only outgoing messages are logged.  If &#39;both&#39;\n&quot;
+                           . &quot;is selected both incoming and outgoing messages are\n&quot;
+                           . &quot;logged.\n\n&quot;
+                           . &quot;Note that this variable applies to all messages. In\n&quot;
+                           . &quot;particular, if this variable is set to &#39;out&#39;, the\n&quot;
+                           . &quot;classlogging variable will have no effect, and no\n&quot;
+                           . &quot;class messages will be logged.&quot;
</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'>&gt; +Sanitizes C&lt;FILENAME&gt; and concatenates it with C&lt;BASE_PATH&gt;.
+
+In any filename, C&lt;&quot;/&quot;&gt; and any control characters (characters which
+match C&lt;[:cntrl:]&gt; get replaced by underscores.  If the resulting
+filename is empty or equal to C&lt;&quot;.&quot;&gt; or C&lt;&quot;..&quot;&gt;, it is replaced with
+C&lt;&quot;weird&quot;&gt;.
+
+=cut
+
+sub sanitize_filename {
+    my $base_path = BarnOwl::Internal::makepath(shift);
+    my $filename = shift;
+    $filename =~ s/[[:cntrl:]\/]/_/g;
+    if ($filename eq &#39;&#39; || $filename eq &#39;.&#39; || $filename eq &#39;..&#39;) {
+        $filename = &#39;weird&#39;;
+    }
</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'>&gt; +    return $m-&gt;log_header . &quot;\n\n&quot; . $m-&gt;log_body . &quot;\n\n&quot;;
+}
+
+=head2 log_header MESSAGE
+
+Returns the header of the message, for logging purposes.
+If you override L&lt;BarnOwl::Message::log&gt;, this method is not called.
+
+=cut
+
+sub log_header {
+    my ($m) = @_;
+    my $sender = $m-&gt;sender;
+    my $recipient = $m-&gt;recipient;
+    my $timestr = $m-&gt;time;
+    return &quot;From: &lt;$sender&gt; To: &lt;$recipient&gt;\n&quot;
</pre>
<p>Should From and To be on different lines?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<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--

home help back first fref pref prev next nref lref last post