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’

Advertisements

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: