2

Problem: I want to be able to log things to my Craft DB from an external app, via some sort of request.

So my first question is, is there any plans for any kind of built-in development log, or should use something like: https://github.com/themusicman/lumberjack/

Second, I'd have to set up some kind of shared key authentication so I could post to this log with an external request.

What tools does Craft/Yii already have for this process, and what would need to be custom development?

3

Craft has Craft::log() for that purpose. Brandon has an example of this function over here

To make this work from an external request, you can create plugin with a controller which saves incoming data (post or json) to the log.

To secure this with a key just send an additional variable and check if it's correct. Take a look at Ben's Dump plugin, for an example of such a key-protected controller.

  • Ok, I see that writes the log file, and not the DB. Is there a way to write to a plugin-specific file, or does it always just go in the craft.log(.x) file? – Tim Kelty Jun 25 '14 at 17:30
  • You can pass a plugin-handle as a log()-parameter, that way a separate log-file for your plugin will be created. (Brandon uses 'mypluginhandle' in his example) -- Otherwise if you want to save it to the DB, you could create a Record class which saves anything you want to the db. – Victor In Jun 25 '14 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.