diff --git a/lib/Staticman.js b/lib/Staticman.js index 5a56eb59..9eeacdc4 100644 --- a/lib/Staticman.js +++ b/lib/Staticman.js @@ -4,6 +4,7 @@ const akismetApi = require('akismet') const path = require('path') const config = require(path.join(__dirname, '/../config')) const errorHandler = require('./ErrorHandler') +const logger = require('./Logger') const GitHub = require('./GitHub') const markdownTable = require('markdown-table') const moment = require('moment') @@ -457,6 +458,9 @@ Staticman.prototype.processEntry = function (fields, options) { this.fields = Object.assign({}, fields) this.options = Object.assign({}, options) + // Create a request ID for our debugging logs - trying to fix #176 + const requestId = uuid.v1() + return this.getSiteConfig().then(config => { return this._checkGithubAuth() }).then(() => { @@ -465,16 +469,60 @@ Staticman.prototype.processEntry = function (fields, options) { // Validate fields const fieldErrors = this._validateFields(fields) + // Log what `fields` looks like at this point - trying to fix #176 + logger.info( + JSON.stringify({ + requestId, + stage: '_checkForSpam', + fields, + }), + null, + 2 + ) + if (fieldErrors) return Promise.reject(fieldErrors) // Add generated fields fields = this._applyGeneratedFields(fields) + // Log what `fields` looks like at this point - trying to fix #176 + logger.info( + JSON.stringify({ + requestId, + stage: '_applyGeneratedFields', + fields, + }), + null, + 2 + ) + // Apply transforms return this._applyTransforms(fields) }).then(transformedFields => { + // Log what `fields` looks like at this point - trying to fix #176 + logger.info( + JSON.stringify({ + requestId, + stage: '_applyTransforms', + fields, + }), + null, + 2 + ) + return this._applyInternalFields(transformedFields) }).then(extendedFields => { + // Log what `fields` looks like at this point - trying to fix #176 + logger.info( + JSON.stringify({ + requestId, + stage: '_applyInternalFields', + fields, + }), + null, + 2 + ) + // Create file return this._createFile(extendedFields) }).then(data => {