How to enable debugging output in Ghost

As I understand Ghost uses ghost-ignition to collect debugging information. How do I enable output when running ghost?

For example, yesterday I was debugging sources with node --inspect-brk current/index.js to figure out why tags page returns 404. The problem was that I didn’t have articles with such tags. I discovered that by inspecting an SQL query in models/plugins/has-posts.js:

const addHasPostsWhere = (tableName, config) => {
    const comparisonField = `${tableName}.id`;

    return function (qb) {
        return qb.whereIn(comparisonField, function () {
            const innerQb = this
                .whereRaw(`${config.joinTable}.${config.joinTo} = ${comparisonField}`)
                .join('posts', '', `${config.joinTable}.post_id`)
                .andWhere('posts.status', '=', 'published');

            debug(`QUERY has posts: ${innerQb.toSQL().sql}`);

            return innerQb;

But then I saw this he statement inside:

debug(`QUERY has posts: ${innerQb.toSQL().sql}`);

Which if enabled would help me figure out the problem faster. How can run Ghost to have an output from these debug statements?

We use the debug module inside of ignition.

You enable it by using a DEBUG environment variable, e.g.

# This will enable debugging for everything
DEBUG=* node current/index.js

And you can make it more specific like

# This will enable debugging for the `knex:query` debugger
DEBUG=knex:query node current/index.js

You can also comma separate the different debuggers to enable - you’ll find more information in the README of the package linked above!

1 Like

Awesome, thanks for the quick response! I’ll explore this functionality