boboldehampsink / import

DEPRECATED - Import plugin for Craft CMS
MIT License
176 stars 28 forks source link

Log will not output from modifyImportRow hook. #137

Closed smockensturm closed 8 years ago

smockensturm commented 8 years ago

Dev mode is false. We are trying to force some logs so we can monitor the data and develop an import helper. Tried nothing in the hook but this, and there is nothing output in the logs.

    function modifyImportRow($element, $map, $data)
    {
        ImportHelperPlugin::log("What is up, yo?", LogLevel::Info, true);
    }

Now, if we put that into the getName method, we get all kinds of logging output.

    function getName()
    {
       ImportHelperPlugin::log("What is up, yo?", LogLevel::Info, true);
       return Craft::t('Import Helper');
    }

Yields several of these:

2016/09/14 09:56:02 [info] [plugin] [Forced] What is up, yo?

What are we doing wrong? What else should we be looking for?

boboldehampsink commented 8 years ago

Can you try the develop branch?

smockensturm commented 8 years ago

Yes. Same. No log.

boboldehampsink commented 8 years ago

Well yeah, you don't get logs if devMode is off. Logs are only saved in devMode true. This is expected behavior.

smockensturm commented 8 years ago

That is simply not true!

Check this answer:

http://craftcms.stackexchange.com/questions/16772/why-cant-we-log-items-regardless-of-dev-mode/16773?noredirect=1#comment23288_16773

And this article, including the following statement:

If you want a log item to appear regardless of whether devMode is enabled, you can pass true as the third argument to the log() method.

https://straightupcraft.com/articles/how-do-i-log-errors-warnings-and-info-in-my-plugins-to-a-craft-log-file

boboldehampsink commented 8 years ago

Ah ok, so you're forcing the log entry?

Edit: duh, my bad

boboldehampsink commented 8 years ago

Well yeah, Craft tasks can show weird behavior when your output buffer is messed up. This can be the result of faulty gzip compression.

Can you try my TaskManager plugin and run the command craft/app/etc/yiic taskmanager run whilst setting runTasksAutomatically to false in craft/config/general.php. This way the task gets run in the command line and not via http.

boboldehampsink commented 8 years ago

fwiw, I always run tasks in a separate worker node to relieve the web node.

smockensturm commented 8 years ago

I'd rather not.

That's just dandy for an ace developer such as yourself, but we have clients breathing down our necks, and we can't afford all this extra time. Thanks for your help.

boboldehampsink commented 8 years ago

I meant just run it once and see if it works. If it does there is something going on with http. If it doesn't there is something else interfering.

smockensturm commented 8 years ago

I have no idea what this task manager is supposed to do or how it works. There is no yiic directory in craft/app/etc

boboldehampsink commented 8 years ago

Sorry, its in craft/app/etc/console. yiic is an executable program. The task manager will run the task in the command line instead of via http/controller.

smockensturm commented 8 years ago

OK. So it appears to have run successfully. What am I looking for? Still no logs for our Import Helper.

boboldehampsink commented 8 years ago

Well, if the logging worked then you would see that in the command line. Can you confirm any other logging (like in getName) is showing up in the command line?

smockensturm commented 8 years ago

Nope. No logs in the console. No logs in runtime.

boboldehampsink commented 8 years ago

That's weird. In the log function there is this line, which should always be executed in your case:

        if (craft()->isConsole())
        {
            echo $msg."\n";
        }

Can you post the complete output of the yiic command?

smockensturm commented 8 years ago

Sure. output.txt

boboldehampsink commented 8 years ago

Okay, as you can see its failing because it can't connect to the db in the command line. Please add a working config in '*' in db.php.

smockensturm commented 8 years ago

There is this.

'*' => array(
        'tablePrefix'   => 'craft',
    ),

And this.

 'aoa.dev' => array(
        'server'        => 'localhost',
        'user'          => 'root',
        'password'      => 'root',
        'database'      => 'craft_aoa'
    ),
boboldehampsink commented 8 years ago

Move that over to '*"

smockensturm commented 8 years ago

I did. Same output.txt .

boboldehampsink commented 8 years ago

Try 127.0.0.1 instead of localhost

smockensturm commented 8 years ago

Same. output.txt

smockensturm commented 8 years ago

Look, man. This is some pretty low-level nonsense for users just trying to build a CMS. We're going to ditch the SmartMap plug-in so we can run your import in devMode, then the logs will output as expected, and I'm going to let you run down why your hook won't honor forced logging.

Edit: have you even tried it?

boboldehampsink commented 8 years ago

Ok. I'm just trying to find out where the issue is, as I'm pretty sure its not in that hook ;-). But if you're good to go, i'll just close this.

smockensturm commented 8 years ago

"Pretty sure?" I think you should try it yourself before you dismiss this. Try forced logging in an Import Helper plug-in that uses the hook and see if it's just me. Report back. It would irresponsible for you not to try and just assume you're "pretty sure" it's not something in your code.

If it's just me, then it's on me and my problem. If it's broke, you should fix it.

Shouldn't take but a fraction of the time it's taken me to help you run this down. Only fair.

smockensturm commented 8 years ago

Well? Did you at least try it? Shouldn't take you more than a few minutes.

boboldehampsink commented 8 years ago

Continued in #138