SQL-level debugging with Midgard

We're currently in the stage where two branches of Midgard: 1.9 and 2.0 are both in active development. Midgard 2 is the fully legacy-free next generation of Midgard, and 1.9 is a transitional release that provides both Midgard 2 and Midgard 1 APIs to ease migration.

The active development status means that bugs are bound to be found in them. For people living on the bleeding edge, it is good to know how to enable SQL-level debugging in case of issues.

Debugging with Midgard 1.x

To start debugging call the following before the troublesome API calls in your code:

mgd_debug_start();

And to end debugging after those API calls:

mgd_debug_stop();

The SQL logs will end up in the Apache error log file.

Debugging with Midgard 2

To start debugging call the following before the troublesome API calls in your code:

midgard_connection::set_debuglevel('debug');

And to end debugging after those API calls:

midgard_connection::set_debuglevel('warn');

The SQL logs will end up in the Midgard log file (as specified in Logfile directive of the unified configuration file).

The SQL logs look something like the following:

midgard-core (pid:8634):(debug):query = SELECT page.id AS midgard_collector_key FROM page, page_i WHERE page.up = 104 AND page.id=page_i.sid AND page_i.lang IN (0, 0) AND page.sitegroup IN (0, 1) AND page.metadata_deleted = 0 

Technorati Tags: midgard, sql


Read more Midgard posts.