Add watchdog logged for bulk generated aliases

stennie - March 19, 2008 - 16:02
Project:Pathauto
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

I find it useful to have bulk updates noted in the watchdog logs, particularly when scheduling via cron (eg. per http://drupal.org/node/236304 ).

Attached is a patch against current cvs head which adds the watchdog logging.

Cheers,
Stephen

AttachmentSize
pathauto_bulk_watchdog.patch3.41 KB

#1

aufumy - May 30, 2008 - 14:58

+1

re-rolled the patch against latest cvs head.

AttachmentSize
pathauto_bulk_watchdog_1.patch3.96 KB

#2

aufumy - May 30, 2008 - 15:00
Status:patch (code needs review)» patch (reviewed & tested by the community)

#3

greggles - May 30, 2008 - 22:39
Version:5.x-2.0» 6.x-1.x-dev
Status:patch (reviewed & tested by the community)» patch (code needs work)

That patch is fine for 5.x but not for 6.x. Can you create one for 6.x as well/first?

#4

aufumy - May 31, 2008 - 15:52

Hi Greggles

Here is a patch for 6.x

Thanks
Audrey

AttachmentSize
pathauto_bulk_watchdog_2.patch3.86 KB

#5

aufumy - May 31, 2008 - 15:53
Status:patch (code needs work)» patch (code needs review)

#6

Freso - May 31, 2008 - 20:35
Status:patch (code needs review)» patch (code needs work)

This won't do: watchdog('pathauto', $update_msg);. watchdog() should be fed the "raw", untranslated string and then handle the translation when displaying the message in the logs. I'm not sure how to handle plurals within watchdog() though, so this might have to be looked into.

Also, I'd vote for waiting with committing this for 6.x-2.x.

#7

greggles - May 31, 2008 - 20:37

That was my concern as well about this being non-trivial for the new watchdog system.

And, yes, let's postpone this to 6.x-2.x.

#8

aufumy - July 26, 2008 - 15:13
Status:patch (code needs work)» patch (code needs review)

re-worked with the new watchdog system.

AttachmentSize
pathauto_bulk_watchdog_drupal6.patch5.5 KB

#9

Freso - July 28, 2008 - 10:07
Version:6.x-1.x-dev» 6.x-2.x-dev

#10

Freso - July 28, 2008 - 12:30
Status:patch (code needs review)» patch (code needs work)

<?php
    $update_msg
= 'Bulk generation of index aliases completed, %aliases generated.';
   
$aliases = format_plural($count, 'one alias', '@count aliases');
?>

is a clear regression of the current code, where "one/@count alias(es)" was a part of the string. First of all, it's splitting one string into two strings, meaning that translators will have to translate some of it out of context. I could easily imagine how "alias" may have to be put differently, depending on what it's an alias of. This would not be possible with the previous patch. Second, it's handing a variable to t() instead of a string.

I'm still not sure how to handle plurals within the watchdog system though, but the way the patch currently does it, is not the way.

#11

Gábor Hojtsy - July 29, 2008 - 06:23

The Drupal 6 watchdog system does not allow other callbacks but t() with watchdog. This might mean that you need to reformulate your text, like 'Bulk generation of index aliases completed (%aliases)' or 'Bulk generation of index aliases completed: %aliases' (I'd prefer the first) and then make %aliases the 'one alias' and '@count aliases'. Thus this breaks the sentence flow, so should be easier to translate.

Drupal 7 should allow arbitrary translation callbacks, such as the Drupal 6 menu system does. We unfortunately did not end up there in Drupal 6, so there are some dirty tricks to be used with plurals in Drupal 6 watchdog.

#12

aufumy - July 29, 2008 - 17:51

Reworked the patch with suggestion 1 from Gabor.

The idea to break out the strings, was inspired from core modules, for example user.module:

$output = t('There is currently %members and %visitors online.',
             array('%members' => format_plural($authenticated_count, '1 user', '@count users'),
                   '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));

AttachmentSize
pathauto_236334_drupal6.patch5.43 KB

#13

Freso - July 29, 2008 - 18:48

Ah well. I bow before Gábor's knowledge of the t() system, though I think it's an ugly hack, but if there's no elegant way of doing it for 6.x... *sigh*

Anyway, there's still a small issue with the patch: most of the $update_msg's (all except one, actually) aren't rounded off by a full stop ("."). I believe they should be, unless there's a reason (e.g., a convention for watchdog messages that I'm not aware of) that the messages shouldn't be treated with proper English grammar. And even if so, the first instance shouldn't have it then. Consistency is King (or something).

#14

aufumy - July 29, 2008 - 21:20
Status:patch (code needs work)» patch (code needs review)

Okay, patch includes full stops.

AttachmentSize
pathauto_236334_drupal6.patch5.43 KB

#15

Freso - July 29, 2008 - 21:33
Status:patch (code needs review)» patch (code needs work)

For some reason, I missed this in my last comment. Sorry to keep you tossing patch versions about. :/ If you don't get around to it first, I'll fix the patch myself when I get around to test, but... the $update_msg instances really ought to be replaced with the string itself, as a PO/T extractor won't know what to work with, if it's given a variable instead of a string.

#16

aufumy - July 30, 2008 - 18:59

While a little annoying, it is actually quite helpful for me, as I learn things I would not otherwise know about.

Also, it is a pleasure to work with module maintainers who are on top of the issue queue.

AttachmentSize
pathauto_drupal6_jul30.patch5.5 KB

#17

Freso - July 30, 2008 - 19:07

I think Greg will testify that I'm one of the Drupal devs who pick on the most nits (but really, I'm just trying aspiring to reach the level of Morbus, chx, et al). Greg has been hit by my nit-picking quite a few times by now. Both before and after he decided to make me a co-maintainer. :p

Anyway, the code looks good now. I can't find anything else to pick on off-hand, but I'd like to comment on the loveliness of drupal_set_message(t( and watchdog('pathauto', aligning perfectly. It's beautiful. :D

And just as I was about to send this off, I noticed an an " alias" which should probably read " $alias". (pathauto_taxonomy.inc, 2nd hunk) ;)

#18

aufumy - August 6, 2008 - 00:22
Status:patch (code needs work)» patch (code needs review)

okay here it is...

AttachmentSize
pathauto_drupal6_aug5.patch5.51 KB
 
 

Drupal is a registered trademark of Dries Buytaert.