We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I’m trying to use getResources with an output tpl chunk that contains a snippet call:
    <tr>
      <td><a href="[[~[[+id]]]]">[[+pagetitle]]</a></td>
      <td>[[!mySnippet?&pid=`[[+id]]`]]</td>
      <td>[[+editedon]]</td>
      <td>[[getUserName?&id=`[[+editedby]]`]]</td>
    </tr>


    I’ve discovered that if ’mySnippet’ contains any sort of logging statements, like
     $modx->log(modX::LOG_LEVEL_ERROR,"mySnippet Ran");

    ...the log data is getting output with the results of the snippet. Further, if ’mySnippet’ itself internally calls any other snippets, and those snippets contain logging statements, they are also returning results that are corrupted by the log data.

    It appears that any snippet calls that are output *by* a snippet call (or at least by getResources- haven’t tried this with other snippets) are spewing the logging data into their output, and messing things up royally.

    Is this a bug? (Or a feature?) Is there a different/preferred way to accomplish what I’m trying to do?



      • 28215
      • 4,149 Posts
      It seems you have a $modx->setLogTarget(’ECHO’) call somewhere, that’s causing your log messages to be ECHO’ed rather than output to core/cache/logs/error.log.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 14883 ☆ A M B ☆
        • 450 Posts
        Quote from: splittingred at Oct 11, 2010, 10:26 AM

        It seems you have a $modx->setLogTarget(’ECHO’) call somewhere, that’s causing your log messages to be ECHO’ed rather than output to core/cache/logs/error.log.

        You wish you could get off that easy, buddy... wink

        If that were the case, then ALL of my log messages would be getting ECHO’ed regardless of how I was calling the snippets, right? But it is only happening in cases where a snippet outputs a snippet call.

        Here’s a simple way to reproduce this:

        1. Create an output chunk for getResources that looks like this:
        id: [[+id]] --- ult parent: [[UltimateParent?&id=`[[+id]]`]]


        2. add a logging command somewhere in UltimateParent:
        $modx->log(modX::LOG_LEVEL_ERROR,"UltimateParent");


        3. Create a resource that both 1) calls UltimateParent directly and 2) calls getResources with the output chunk that calls UltimateParent:
        [[UltimateParent?&id=`39`]]
        [[getResources?&parents=`5`&tpl=`resTpl`]]


        Now fire up the grill, view that resource and let me know what happens. I’ll wait smiley


          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: splittingred at Oct 11, 2010, 10:26 AM

          It seems you have a $modx->setLogTarget(’ECHO’) call somewhere, that’s causing your log messages to be ECHO’ed rather than output to core/cache/logs/error.log.
          I’m getting the same. It seems that the current getResources snippet has a setLogTarget(’ECHO’) in it. Grrr.

          You can remove this manually for now, and I’ll get the snippet updated today.
            • 14883 ☆ A M B ☆
            • 450 Posts
            Good to know that its just getResources and not a core thing. Thanks for checking it.