Page MenuHomePhabricator

Use non-static calls in EventLogging
Closed, DeclinedPublic

Description

Right now EventLogging uses static calls (i.e. mw.eventLog.logEvent() instead of var logger = mw.eventLog.create(); logger.log(). This is a bad practice, in part because it makes testing harder (not that much of a problem in Javascript where "static" is not a language, worse in PHP), in part because there is no way to attach state so the only way to add information to the logged data is by adding more parameters. This makes changes such as T67500 or T87459 awkward.

There should be a way to create EventLogging instances, mw.eventLog should be an instance with default properties, and there should be an easy way to get a clone that instance so that its properties can be changed.

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr subscribed.

What properties or state would you need to change (outside tests). I don't see any public supposed-to-be-mutable-state or set-methods in EventLogging's client-side. Sounds like maybe you want to wrap it in a class of your own with configuration settings related to your application.

Tgr claimed this task.

I don't think there are any right now, but that's because some tasks that should be solved in EL are pushed to clients (see bugs linked from the description).

That said the approach in T109398 (per-schema objects) probably makes more sense.