<< Previous | Next >>

log_format

char * log_format( LogEntry *le, char *buffer, int length, int pfx );

Description

Given the log entry returned by log_next() or log_prev(), format the entry as an ASCII string. The string is constructed in Unix "syslog" format:

<%d>%.15s %.8s[%d]: %s

where the substitutions are:

%d: facility/priority as decimal number (0-255)
%.15s: date/time as "Mon dd hh:mm:ss"
%s: process name - taken from LOG_UDP_PNAME(0) if defined, else "" (empty).
%d: process ID, but the entry serial number is used instead.
%s: the log entry data.

A null terminator is always added at buffer[length-1], or at the end of the string if it fits in the buffer. If pfx is zero, then the above syslog prefix is not generated.

NOTE Please see the comments at the top of log.lib for a description of the message logging subsystem.

Parameters

le
Log entry result from log_next/log_prev().

buffer
Storage for result. Must be dimensioned at least 'length'.

length
Length of buffer. For the maximum sized log entry, the buffer should be 158 bytes. The minimum length must be greater than or equal to 43 (if pfx true) else 1. If a bad length is passed, the function returns without writing to buffer.

pfx
0: message text only; do not generate syslog prefix.
1: prefix plus message text.
2: prefix only (up to ']', then null terminator).


Return Value

buffer address, or NULL if bad length passed.

Library

log.lib

See Also

log_next, log_prev


Dynamic C Functions << Previous | Next >> rabbit.com