[Dancer-users] Dancer logging stringifies some data

Ovid curtis_ovid_poe at yahoo.com
Thu Jun 21 18:00:54 CEST 2012


Hi all,

I don't have the time to fix this right now, but we had a very interesting issue. I had this line in my code:

  info "Bidding on auction $id", $bid;

That turned out to be a massive bug!

$bid is a hashref that gets serialized to JSON. Unfortunately, the act of printing out the data flipped one value from an NV (float) to a PV (string). That caused the JSON serializer render 1.2 as "1.2". Sadly, the system I was sending this data to reported a bizarre "Request throttled" error instead of a JSON validation error.

The simple fix was to drop the $bid from the info() and add a test to ensure that I have a NV instead of a PV.
 
If anyone wants to look into this, that would be great. Perhaps adding optional cloning of the data in the logger prior to printing it out? (Optional because it might be expensive)

Cheers,
Ovid
--
Live and work overseas - http://www.overseas-exile.com/
Buy the book           - http://www.oreilly.com/catalog/perlhks/
Tech blog              - http://blogs.perl.org/users/ovid/
Twitter                - http://twitter.com/OvidPerl/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120621/c43c6cab/attachment.htm>


More information about the Dancer-users mailing list