eliot icon indicating copy to clipboard operation
eliot copied to clipboard

MemoryLogger logs whole objects rather than serialized fields

Open jml opened this issue 9 years ago • 2 comments

When trying to write unit tests for an ActionType I was surprised that I was getting the logged object in the logger, rather than the serialized form.

I've written a failing test that shows this.

I'm not 100% sure it's a code bug though, because while writing this I found MemoryLogger.serialize, which seems to get me the behaviour I want. At the very least, it's a documentation bug, because the page on unit testing your logging is silent on the subject of serialization.

jml avatar Jun 28 '15 16:06 jml

I believe this is intentional because it is often useful to have access to the to-be-serialized object rather than the lossy serialized data.

Although being able to test against the serialized task is useful too, which #95 addresses.

jonathanj avatar Jun 28 '15 16:06 jonathanj

Well, there's a serialize method, which would address it too, and with less code than #95. Although it would still need to be documented somewhere other than the source code.

If it's intentional behaviour, then the guide on unit testing your logging should probably be updated.

jml avatar Jun 29 '15 08:06 jml