Contents

OSLogInt32ExtendedFormat.bitrate

A format that displays a 32-bit integer as a bit rate.

Declaration

case bitrate

Discussion

Use this option to format the interpolated value as a bit rate, such as 100 kbps. The following example applies the bitrate formatter to the 32-bit integer value 100_000:

// Create a logger with the specified subsystem and category.
let logger = Logger(subsystem: "com.example.OSLogValueFormatting",
                    category: "Formatter Output")
                
// Assign the value to interpolate.
let value: Int32 = 100_000
                
// Write the value to the log using the specified format.
logger.info(".bitrate output is \(value, format: .bitrate)")

And the system writes the following message to the log:

[Formatter Output] .bitrate output is 100 kbps

See Also

Getting the Formats