mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-01 10:55:17 +00:00
improve logging by avoiding string escapes
This commit is contained in:
parent
b44a7b9aa6
commit
ba0de92081
1 changed files with 8 additions and 6 deletions
|
@ -7,16 +7,18 @@ if 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
|
||||
JSON.parse(
|
||||
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 {
|
||||
rawUpdate: truncateFn
|
||||
rawUpdates: truncateFn
|
||||
newUpdates: truncateFn
|
||||
rawUpdate: truncateFn
|
||||
lastUpdate: truncateFn
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue