Closed (fixed)
Project:
Apache log4php integration
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
25 May 2012 at 20:52 UTC
Updated:
30 Oct 2012 at 16:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
andreiashu commentedI think a better solution would be to not put the log message body through format_string() function which t() uses. The attached patch provides a clone of t() with the only exception that log4php_t() skips calling format_string.
Comment #2
andreiashu commentedComment #3
andreiashu commentedbetter title?
Comment #4
andreiashu commentedadded '// Construct plain-text message' back :)
Comment #5
erikwebb commentedWhat's the danger of
format_string()? If we're trying to keep some tags, why not just change the sanitization to!variable? This information is never available through Drupal, so I don't believe there's a security issue in that. I think this is a more manageable approach that replacing thet()function.On a separate note, I suppose we should actually use
get_t()in case the database isn't available yet.Comment #6
andreiashu commentedI'm not sure I understand "why not just change the sanitization to !variable?"
All messages that come from core and contrib will have % or @ or ! in them. You can't change that.
Do you suggest replacing all '@' and '%' to '!variable' in log4php watchdog implementation? I would not like to do that to be honest
Comment #7
erikwebb commentedJust looking through my dblog, there are examples of other modules logging rich messages. Are you having this problem with some modules in particular? I'm inclined to just follow whatever formatting the original module set.
Comment #8
andreiashu commentedHi Erik,
I gave this issue a bit more thought and I think you might be (partially) right :)
I'l like to step back and reiterate (even though we already know this) what the default logging (dblog module) system does:
Regarding displaying of the messages, DBlog's approach works just fine when all you want to do is see your messages in the browser.
Obviously, when you want to tail your logs within a file (within a terminal) this approach doesn't work well which is what the initial patch was trying to fix.
Now, the additional issue we face is that Log4PHP can have appenders to any kind of source so we should take that into consideration.
Considering the above I think it might be a good idea to try and let the user/sysadmin decide how he/she wants this module to behave. So I reckon providing a sane default with the option to customise would be the best of both worlds instead of hardcoding it as per my patch, or doing
strip_tagson the message before inserting it as current code does.I'll provide a patch soon, until then let me know if this approach makes any sense.
Comment #9
erikwebb commentedI like your idea. Have a default implementation that can be overridden by another module. This is basically how the theme system works, but I obviously don't want to use the theme system for this module. How would you recommend using this and configuring? Documented settings.php variable? Some sort of basic UI? (I'd rather not have a UI for this module, since the whole point is to bring logging outside of Drupal.)
Comment #10
andreiashu commentedI was thinking that we can provide different log4php Layouts for this that will deal with formatting/stripping of the message.The user of the module would then only reference the relevant Layout in their log4php.xml file.
From what I can see custom modules can use $conf['log4php_config'] at hook_init() time (as long as they are loaded before log4php module) to alter that config during run time. I don't like globals like that but for the time being it works and (unfortunately) it is a Drupal thing so module developers will be aware of it.
Comment #11
erikwebb commentedSo should we create a Drupal-friendly Layout to start with and simply recommend that?
Comment #12
andreiashu commentedYes that should work. I'll try and do it this weekend, but I don't mind if you beat me to it :)
Comment #13
andreiashu commentedThat was a looong weekend :)
Assigning to myself so I can take of it soon
Comment #14
andreiashu commentedAttached patch provides renderers that are Drupal aware. It also sets the default renderer to
LoggerRendererDrupalPlainLocaleObjectwhich will do what the patch in comment #4 did: log a localised version of the message without passing the message through format_string().Comment #15
andreiashu commentedOops I forgot to add the renderers to the patch. This one is the correct thing
Comment #16
erikwebb commentedAll makes sense to me.
http://drupalcode.org/project/log4php.git/commit/4b5eb30
Comment #17
andreiashu commentedHey Erik,
I downloaded the stable build archive and it doesn't contain the includes directory
I think you might have merged the patch from #14rather than #15 which actually contains the renderer files.
Comment #18
erikwebb commentedSorry about that. Must have pulled your patch before the second one was posted.
https://drupal.org/node/1814450
Comment #19.0
(not verified) commentedtypo