I finally found the time to read http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins and I have some questions:
1. Why the the class fields use
? The second option would be much easier to type.
2. Why is the init method not implemented like
parent::init(‘c’, self::LEVEL_PARTICIPATING, ‘…’);
$this->standard_init(‘c’, self::LEVEL_PARTICIPATING, ‘…’);
rather than three lines of code? (Presumably not the former because it involves overriding a method while changing the argument list which gets confusing, but the second version would be more succinct.)
3. Why is ‘crud’ done with literal strings, but ‘edulevel’ done with constants? Consistent APIs are better.
4. I still don’t understand what get_description is for. The description in the page is unsatifying. It seems less good than print_object($event) or class_name($event), while require effort to create.
5. What is the stylistic best practice regarding chaining ->trigger onto the create() call?
6. The contract around add_record_snapshot seem very unclear. Under what circumstances can event receiving code rely on the data being there? If date you need and expect is not there, what do you do?
7. Right at the end of the page, it says “Please never forget that you have to bump the plugin version in order to get all the new events ‘installed’”. Seems like good advice, but why it is right at the end! I suggest adding it right at the top when explaining how to define a new event. Oops! “it’s a wiki”. OK, I fixed that.
8. I am still very disappointed in how un-expressive this API is. Logging is conceptually very simple. The amount of code you need to write to log one thing is far larger than necessary. The goal of these changes was to get people to log more, to increase the powder of analytics. I fear the effect of these changes will be the opposite. Logging something is such hard work that people will only log the bare minimum. (Sorry, you are probably bored of hearing me say that.)
9. Can anyone satisfy my curiosity about edulevel? It seems the complete opposite to Moodle’s social constructionist roots. Has it been inspired by some external standard (e.g. TinCan), or did we make it up. In either case, why?