Quellcode durchsuchen

Improve/fix serializers for update logging (#80)

* Improve/fix serializers for update logging
Simon Detheridge vor 7 Jahren
Ursprung
Commit
06444d2cc4
1 geänderte Dateien mit 17 neuen und 2 gelöschten Zeilen
  1. 17 2
      services/document-updater/app/coffee/LoggerSerializers.coffee

+ 17 - 2
services/document-updater/app/coffee/LoggerSerializers.coffee

@@ -1,10 +1,25 @@
+_ = require('lodash')
+
 showLength = (thing) ->
 showLength = (thing) ->
-	"length: #{thing?.length}"
+	if thing?.length then thing.length else thing
+
+showUpdateLength = (update) ->
+	if update?.op instanceof Array
+		copy = _.cloneDeep(update)
+		copy.op.forEach (element, index) ->
+			copy.op[index].i = element.i.length if element?.i?.length?
+			copy.op[index].d = element.d.length if element?.d?.length?
+			copy.op[index].c = element.c.length if element?.c?.length?
+		copy
+	else
+		update
 
 
 module.exports =
 module.exports =
 	# replace long values with their length
 	# replace long values with their length
 	lines: showLength
 	lines: showLength
 	oldLines: showLength
 	oldLines: showLength
 	newLines: showLength
 	newLines: showLength
+	docLines: showLength
+	newDocLines: showLength
 	ranges: showLength
 	ranges: showLength
-	update: showLength
+	update: showUpdateLength