Wikia/app — pull request #3674 by drsnyder (2014-05-23 21:43:40+00:00)
Title: Move WikiaLogger from extensions to lib/Wikia & remove global state

This pull request is the result of the effort to add more instrumentation to our SQL logging. More specifically, to allow us to send SQL logs to ES/Kibana for better search and post processing. See [PLAT-170](https://wikia-inc.atlassian.net/browse/PLATFORM-170).

Invoking `WikiaLogger::instance()` from `DatabaseMysql` would mean calling an extension form within the core of MediaWiki which doesn't seem right. This pull request moves the `WikiaLogger` to `lib/Wikia` and establishes a convention for files, paths, and tests in `lib/Wikia` that confirm to [PSR-4](https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader.md).

The `lib/Wikia` directory now contains `src` and `tests` directories. All of the classes created under `/lib/Wikia` should be in the `Wikia` namespace. If the classes conform to PSR-4[0] they will be autoloaded into the app. An XML test driver has also been supplied under `lib/Wikia/tests/phpunit.xml ` for running the tests created within the namespace.

All third party PHP libraries should be managed by [composer](https://getcomposer.org/) if possible and will be installed under `lib/composer`. As part of this pull request, monolog and the Psr logging library are being moved out of `/lib/vendor` and into `lib/composer` using composer. Since composer relies upon external resources to manage packages and dependencies we are loading these dependencies into `lib/composer` and checking them into the app repository. This is not ideal but until we can manage those external dependencies ourselves we don't want them to be part of the deploy pipeline.

There is an existing exception to this that is being migrated to PSR-4 compliance in an external repository so that it can be managed by composer. See https://github.com/Wikia/fluent-sql-php/pull/1.

The `WikiaLogger` can now be configured directly on the object instead of using a global variable (`$wgDevESLog`). The configuration is done using the following (hopefully self explanatory) methods:

* `WikiaLogger::instance()->setProductionMode()`
* `WikiaLogger::instance()->setDevMode()`
* `WikiaLogger::instance()->setDevModeWithES()`

One gap that still remains is the proper location for initialization. I've capture it in the TODO below.

TODO:
* [ ] Wire in mode setting in the most appropriate place to ensure low level coverage in production.

/cc @Wikia/platform-team