5.7.1 Output Format String

The format string is composed of zero or more directives: ordinary characters (not ‘%’), which are copied unchanged to the output; and conversion specifications, each of which is replaced with the result of a corresponding conversion. Each conversion specification is introduced by the character ‘%’, and ends with a conversion specifier. In between there may be (in this order) zero or more flags, an optional minimum field width and an optional precision.

Flags

0

The value should be zero padded. This affects all floating-point conversions, i.e. ‘w’ and ‘{...}’, for which the resulting value is padded on the left with zeros rather than blanks. If the ‘0’ and ‘-’ flags both appear, the ‘0’ flag is ignored. If a precision is given with a floating-point conversion, the ‘0’ flag is ignored. For other conversions, the behavior is undefined.

-

The converted value is to be left adjusted on the field boundary. (The default is right justification.) Normally, the converted value is padded on the right with blanks, rather than on the left with blanks or zeros. A ‘-’ overrides a ‘0’ if both are given.

' ' (a space)

A blank should be left before a positive number (or empty string) produced by conversion.

The field width

An optional decimal digit string (with non-zero first digit) specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left (or right, if the ‘-’ flag has been given).

In no case does a nonexistent or small field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result.

The precision

An optional precision, in the form of a period (‘.’) followed by an optional decimal digit string. If the precision is given as just ‘.’, or the precision is negative, the precision is taken to be zero. This gives the number of digits to appear after the radix character for floating-point conversions or the maximum number of characters to be printed from a string, for string conversions.

The conversion specifier

A character or a sequence of characters that specifies the type of conversion to be applied. The conversion specifiers are replaced in the resulting output string as described in the table below:

i

The server identifier.

h

The server hostname, as set by the host configuration directive.

w

Computed relative load.

{var}

The value of the variable var.

{@expr-name}

The result of evaluating expression expr-name in the context of the current server.

(macro)

Expansion of the macro.

%

The percent character.