<html><body><div style="font-family: garamond,new york,times,serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Raghavendra Gowdappa" &lt;rgowdapp@redhat.com&gt;<br><b>To: </b>"Nithya Balachandran" &lt;nbalacha@redhat.com&gt;<br><b>Cc: </b>gluster-devel@gluster.org<br><b>Sent: </b>Monday, April 28, 2014 11:39:50 AM<br><b>Subject: </b>Re: [Gluster-devel] Glusterfs and the new logging framework<br><div><br></div>(Moving the discussion to gluster-devel).<br><div><br></div>----- Original Message -----<br>&gt; From: "Nagaprasad Sathyanarayana" &lt;nsathyan@redhat.com&gt;<br>&gt; To: "Nithya Balachandran" &lt;nbalacha@redhat.com&gt;<br>&gt; Cc: "Raghavendra Gowdappa" &lt;rgowdapp@redhat.com&gt;, "Susant Palai" &lt;spalai@redhat.com&gt;, "Atin Mukherjee"<br>&gt; &lt;amukherj@redhat.com&gt;, "Varun Shastry" &lt;vshastry@redhat.com&gt;, "Krishnan Parthasarathi" &lt;kparthas@redhat.com&gt;,<br>&gt; "Ravishankar Narayanankutty" &lt;ranaraya@redhat.com&gt;, "Pranith Kumar Karampuri" &lt;pkarampu@redhat.com&gt;, "Venkatesh<br>&gt; Somyajulu" &lt;vsomyaju@redhat.com&gt;<br>&gt; Sent: Monday, April 28, 2014 10:53:55 AM<br>&gt; Subject: Re: Glusterfs and the new logging framework<br>&gt; <br>&gt; It is a very valuable suggestion Nithya. &nbsp;Using descriptive message IDs<br>&gt; (DHT_GET_CACHED_SUBVOL_FAILED in place of dht_msg_1) is definitely helpful<br>&gt; to developers and improves the code readability. &nbsp;However, IMO, keeping the<br>&gt; actual formatted message string in a header file is a good practice. &nbsp;Some<br>&gt; of the reasons for it are;<br>&gt; <br>&gt; A&gt; It helps in internationalization and localization at later point.<br>&gt; B&gt; Any changes to the message &amp; the formatting is easy to handle when it is<br>&gt; not embedded in the log function call.<br>&gt; <br>&gt; Please discuss this with wider audience, including Vijay &amp; Alok, before<br>&gt; finalizing the approach.<br>&gt; <br>&gt; Thanks<br>&gt; Naga<br>&gt; <br>&gt; ----- Original Message -----<br>&gt; From: "Nithya Balachandran" &lt;nbalacha@redhat.com&gt;<br>&gt; To: "Raghavendra Gowdappa" &lt;rgowdapp@redhat.com&gt;, "Susant Palai"<br>&gt; &lt;spalai@redhat.com&gt;, "Atin Mukherjee" &lt;amukherj@redhat.com&gt;, "Varun Shastry"<br>&gt; &lt;vshastry@redhat.com&gt;, "Krishnan Parthasarathi" &lt;kparthas@redhat.com&gt;,<br>&gt; "Ravishankar Narayanankutty" &lt;ranaraya@redhat.com&gt;, "Pranith Kumar<br>&gt; Karampuri" &lt;pkarampu@redhat.com&gt;, "Venkatesh Somyajulu"<br>&gt; &lt;vsomyaju@redhat.com&gt;<br>&gt; Cc: "Nagaprasad Sathyanarayana" &lt;nsathyan@redhat.com&gt;<br>&gt; Sent: Monday, April 28, 2014 9:16:37 AM<br>&gt; Subject: Glusterfs and the new logging framework<br>&gt; <br>&gt; Hi,<br>&gt; <br>&gt; I am currently working on porting the DHT messages to the new logging<br>&gt; framework and I have some observations/concerns about the approach on the<br>&gt; same:<br>&gt; <br>&gt; 1. With the current approach, a call to gf_msg would look like:<br>&gt; <br>&gt; gf_msg ("dht", GF_LOG_ERROR, 0, dht_msg_1, param1);<br>&gt; <br>&gt; This provides little information to the developer when going through the<br>&gt; code. It becomes tedious to lookup the value of dht_msg_4 each time. This<br>&gt; also reduces code readability as the format string is not available<br>&gt; instantly and can potentially cause issues with incorrect parameters being<br>&gt; passed to the call.<br>&gt; <br>&gt; <br>&gt; 2. Adding new messages can potentially cause us to use up the chunk of<br>&gt; message ids quickly. A better approach would be to decouple the is<br>&gt; definition from the actual message string.There are be several potential<br>&gt; messages for a single operation state.Message formats might change in the<br>&gt; future as we add enhancements - for eg, we shouldn't have to add new<br>&gt; messages with new message ids to accommodate an additional parameter if we<br>&gt; change a struct definition, say. Defining some sort of "state ids" however<br>&gt; will take up fewer ids.<br>&gt; <br>&gt; Eg: The code has the following messages :<br>&gt; <br>&gt; "Failed to get cached subvol for %s"<br>&gt; "Failed to get cached subvol for %s on %s"<br>&gt; <br>&gt; <br>&gt; Both the above will require separate msg-ids with the current approach. The<br>&gt; difference in the strings is minimal and does not really provide any<br>&gt; additional information from the Doxygen doc point of view.<br>&gt; <br>&gt; Another approach would be to define a DHT_GET_CACHED_SUBVOL_FAILED id which<br>&gt; can be passed to the msglog, while the actual message string can change<br>&gt; depending on what the developer thinks will be helpful. This will also<br>&gt; improve code readability.<br>&gt; <br>&gt; So I propose that we do the following:<br>&gt; <br>&gt; <br>&gt; Current approach:<br>&gt; <br>&gt; Messages file:<br>&gt; <br>&gt; #define dht_msg_1 (GLFS_COM_BASE + 1) , "Failed to get cached subvol for %s"<br>&gt; #define dht_msg_2 (GLFS_COM_BASE + 2) , "Failed to get cached subvol for %s<br>&gt; on %s"<br>&gt; #define dht_msg_3 (GLFS_COM_BASE + 3) , "Failed to get hashed subvol " ...etc<br>&gt; etc<br>&gt; <br>&gt; Code :<br>&gt; gf_msg ("dht", GF_LOG_ERROR, 0, dht_msg_1, param1);<br>&gt; <br>&gt; gf_msg ("dht", GF_LOG_ERROR, 0, dht_msg_2, param1, param2);<br>&gt; <br>&gt; The above is confusing for a developer.<br>&gt; <br>&gt; <br>&gt; Proposed approach:<br>&gt; <br>&gt; #define DHT_GET_CACHED_SUBVOL_FAILED (GLFS_COM_BASE + 1)<br>&gt; #define DHT_GET_HASHED_SUBVOL_FAILED (GLFS_COM_BASE + 2)<br>&gt; <br>&gt; gf_msg ("dht", GF_LOG_ERROR, 0, DHT_GET_CACHED_SUBVOL_FAILED, "Failed to get<br>&gt; cached subvol for %s on %s" , param1, param2);<br>&gt; <br>&gt; gf_msg ("dht", GF_LOG_ERROR, 0, DHT_GET_CACHED_SUBVOL_FAILED, "Failed to get<br>&gt; cached subvol for %s " , param1);<br>&gt; </blockquote><div>I am guessing the original author of the new logging framework decided to retain the msg string (like "Failed to get cached subvol for %s")</div><div>in the header file due to the ease with which the one-to-one mapping between the msg id and the message itself can be captured using scripts/tools</div><div>which may be needed for documentation - something that becomes difficult with the proposed approach.<br></div><div><br></div><div>Even from development perspective, it is much easier for a developer adding new code (which means many more calls to gf_msg())</div><div>to merely look up one single place (which would be the messages header file for that component) to determine whether the message he/she is about to log<br></div><div>is already in use (for example to know whether DHT_MSG_1 can be reused in their changes), rather than having to look up all files in that component.<br></div><div><br></div><div>-Krutika<br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">&gt; <br>&gt; Advantages:<br>&gt; Much clearer code - developer can use generated id or define new one easily.<br>&gt; Related ids can be grouped together in the header file.<br>&gt; Fewer ids required<br>&gt; No changes to the logging framework<br>&gt; Messages can change later<br>&gt; The approach of using and id and generating a doxygen doc for the same still<br>&gt; holds good - we are simply decoupling the actual string from the definition.<br>&gt; So the doc would still have the message id and a description of the<br>&gt; condition it specifies without tying it to a string that might change later.<br>&gt; <br>&gt; <br>&gt; Thoughts?<br>&gt; <br>&gt; Regards,<br>&gt; Nithya<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>_______________________________________________<br>Gluster-devel mailing list<br>Gluster-devel@gluster.org<br>http://supercolony.gluster.org/mailman/listinfo/gluster-devel<br></blockquote><div><br></div></div></body></html>