add logging of raw updates

This commit is contained in:
Brian Gough 2016-01-26 11:28:02 +00:00
parent 29c7c5e249
commit b3ddd839e6
2 changed files with 16 additions and 1 deletions

View file

@ -1,10 +1,24 @@
Settings = require "settings-sharelatex"
logger = require "logger-sharelatex"
logger.initialize("track-changes")
TrackChangesLogger = logger.initialize("track-changes").logger
if Settings.sentry?.dsn?
logger.initializeErrorReporting(Settings.sentry.dsn)
# log updates as truncated strings
truncateFn = (updates) ->
JSON.stringify updates, (key, value) ->
if typeof value == 'string' && (len = value.length) > 80
return value.substr(0,32) + "...(message of length #{len} truncated)..." + value.substr(-32)
else
return value
TrackChangesLogger.addSerializers {
rawUpdates: truncateFn
newUpdates: truncateFn
lastUpdate: truncateFn
}
Path = require "path"
Metrics = require "metrics-sharelatex"
Metrics.initialize("track-changes")

View file

@ -102,6 +102,7 @@ module.exports = UpdatesManager =
# parse the redis strings into ShareJs updates
RedisManager.expandDocUpdates docUpdates, (error, rawUpdates) ->
return callback(error) if error?
logger.log project_id: project_id, doc_id: doc_id, rawUpdates: rawUpdates, "retrieved raw updates from redis"
UpdatesManager.compressAndSaveRawUpdates project_id, doc_id, rawUpdates, temporary, (error) ->
return callback(error) if error?
logger.log project_id: project_id, doc_id: doc_id, "compressed and saved doc updates"