console: Support formatting options in trace()

Fix #4589