[cost] Silence the log in non-debug mode and refactor
[cost] Silence the log in non-debug mode and refactor

Reviewed By: jvillard

Differential Revision: D25023798

fbshipit-source-id: 7741ee6f8

facebook/infer,facebook/infer,facebook/infer,jvillard/infer,jvillard/infer,jvillard/infer,facebook/infer,jvillard/infer,facebook/infer,jvillard/infer,facebook/infer,jvillard/infer,facebook/infer,jvillard/infer