In debug and log messages, put the data at the end, not the middle.

In messages where a big string may be inserted, prefer “something something %s” over “something %s something”.

Example:
In this example, %s is a long hex-string representing an array’s contents.

Bad:

[DECODE] [DEBUG] Was passed array ‘%s’ for processing

Good:

[DECODE] [DEBUG] Was passed array for processing: ‘%s’

Best:

[DECODE] [DEBUG] Function myDecodeFunc called with myArray = ‘%s’

2 Responses to “In debug and log messages, put the data at the end, not the middle.”

  1. Zorm Says:

    But why?!

  2. yoni Says:

    It makes copying and pasting, or log processing, easier and more intuitive. Logs aren’t where you want to have a grammatically nice UI – you just want better logging.

Leave a Reply