Skip to content

Commit

Permalink
Log fields multiple times per request. eduardoboucas#176
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Jun 13, 2018
1 parent 44f95c6 commit bd1cf56
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/Staticman.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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(() => {
Expand All @@ -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 => {
Expand Down

0 comments on commit bd1cf56

Please sign in to comment.