Function setStatsHandler

Sets a stats handler that can be used for debugging or analyzing use. Not recommended for production environments