User:Mariapacana/OPW Progress Report

Week 1: December 10 to December 16

 * 1) Familiarized myself with developer tools like Bugzilla, Mediawiki Gadgets, Gerrit, etc.
 * 2) Submitted patch to streamline the setting of debugging flags.
 * 3) Researched different ways of dynamically debugging Node applications (e.g., node-debugger, node-inspector).
 * 4) Began working on disabling generic tracing (e.g., --trace without any tracing flags).

Week 2: December 17 to December 23

 * 1) Continued to work on disabling generic tracing.
 * 2) Learned about how the parser pipeline works and how different transformations relate to one another.

Week 3: December 24 to December 30

 * 1) Cleaned up some indentation errors and typos (patch 1, patch 2).
 * 2) Disabled generic tracing (e.g., --trace without any tracing flags; patch).
 * 3) Began working to create a generic error logging function in Util.js. (in-progress patch)

Week 4: December 31 to January 6

 * 1) Transferred logger function from Util module to its own class, on mentor's suggestion (patchset 4).
 * 2) Added wrapper functions such as trace and debug
 * 3) Visited User:Ssastry in Minnesota! Learned how...
 * 4) * Synchronous & synchronous token transform managers transform Wikitext to HTML
 * 5) * Parsoid evolved and how it relates to the original PHP parser
 * 6) * Parsoid tests work; how/why some tests are blacklisted

Week 5: January 7 to January 13

 * 1) Moved logging function from own class into MWParserEnvironment object ("env"), after getting feedback from the team (patchset 9).
 * 2) * The many-logger approach was considered overly complex; abandoned in favor of a single log function that dispatches to different backends.
 * 3) * Consequently, we put the logger into the env object, which is widely available throughout Parsoid codebase and has access to tracing / debugging flags.
 * 4) Removed wrapper functions (e.g., trace, debug) from logging, consolidating everything into a single all-purpose function.

Week 6: January 14 to January 20

 * 1) Rewrote logger function (patchset 12)
 * 2) Began rewriting error and warning messages to use logging function (patchsets).
 * 3) Wrote blog post about meeting my mentor in person.

Week 7: January 21 to January 27

 * 1) Continued to replace error and warning messages throughout the codebase. (patch 1, patch 2)
 * 2) After User:cscott made enhancements to the logging function so that it could accept arbitrarily many parameters, checked all function calls to make sure they still worked.

Week 8: January 28 to February 3

 * 1) Updated patch for replacing error / warning messages. (patch 6,patch 7, patch 8)
 * 2) * Based on team feedback, rewrote logger function to accommodate logging to different backends (e.g., files, HTTP response objects).
 * 3) * Again moved the logger function into its own Logger class, although it will still continue to be accessed from the MWParserEnvironment object.
 * 4) Began replacing tracing and dumping calls with logger function. (patch 1)
 * 5) Wrote blog post about the Parsoid team's consensus-based code review process.

February 2014
Month of the Never-Ending Error Logging Patch

Week 9: February 4 to February 10

 * 1) patchset 9
 * 2) * Set up default backend to log errors to and made it possible to register new backends (generally error callback functions).
 * 3) * Make logger exit process when logType is fatal.
 * 4) patchset 17
 * 5) * Changed emitMessage to emit an object to a logging backend, rather than a message string.
 * 6) * Made it possible to register backends using regular expressions in addition to strings.

Week 10: February 11 to February 17

 * 1) patchset 18
 * 2) * When the logType is fatal, wait until all backends are logged to before ending the process.
 * 3) Began to address recursive error logging issue.
 * 4) * Parsoid service on main branch crashed the servers because of a recursive error logging problem in Connect (middleware handler for Node). Researched the cause of the error logging problem in the main branch, as well as ways to prevent infinite recursion in my logger branch.

Week 11: February 18 to February 24

 * 1) patchset 19
 * 2) * Changed Logger to prevent recursive logging. If the logger is currently processing a log request but gets called again, it ignores the subsequent call unless the logType is fatal. If the logType is fatal, the process must be ended.
 * 3) * Used Node.js's async.parallel to log to a default backend after all other backends have been logged to.

Week 12: February 25 to March 3

 * 1) Submitted patchset 22
 * 2) * Restructured Logger class to remove nested functions
 * 3) * Changed log levels; now "fatal/request" ends an HTTP response *and* terminates a process, while "fatal" ends an HTTP response. Additionally, "error" is for errors that must be known about at runtime, while "warning" is for errors that do not need to be known at runtime.
 * 4) * In Parsoid web server, added helper method / flags to prevent headers from being set twice (triggering infinite recursion issue in Connect.)
 * 5) Blogged about my never-ending patch, and some ideas about how to avoid doing that.

Week 13: March 4 to March 10

 * 1) Never-ending logger patch got merged at last!
 * 2) Submitted first versions of patch to support structured logging (with arbitray input data) and to allow logging backends to customize their messages.
 * 3) Made the --quiet option on parserTests truly quiet (patch).
 * 4) Converted some tracing code to env.log (tokenstreampatcher patch, peg-tokens patch)
 * 5) Blogged about a favorite Javascript trick I picked up while working on Parsoid (first post in a series of 5)

Project Status
My main accomplishment during this project was creating a Logger class that could be used throughout the Parsoid codebase in lieu of console.log / console.warn. The logger can send logging data to a variety of backends (console, file, HTTP response object), and will end a process if the logType is "fatal". The logger is now being used to log the vast majority of errors and warnings throughout the codebase, although tracing and dumping is still being done the old way.

I'll be working over the next week (3/10 - 3/17?) or so to wrap up some loose threads. Specifically, I intend to get the structured logging and lazy message construction patch merged in, rewrite the logger to support dumping flags, and replace some traces / dumps to use the logger.