fprintfile

    #include <mplib1/fprintfile.h>
This file contains a number of function definitions, the most popular of which is
    int fprintfile( FILE *fp, char *format, ... );
The fprintfile function provides an extended version of fprintf which prepends the resultant string with a timestamped log string generated using make_log_str().

An example of the output of this routine would be

    fprintfile( stderr,"find_customer: <%s> failed. Error %d\n",
		cust_name, errno );
produces
    1996-12-31 13:45:56.78Z 22301 myname find_customer: <bloggs> failed. Error 3003


make_log_str

    char *make_log_str( char *buffer );
The make_log_str function generates a string suitable for placing in a log file or outputting to a user.

The string consists of a high-resolution timestamp created by make_timestamp_str(), the process id, and the process owner.

The buffer parameter specifies a data area in which to create this string. If it is provided it should be at least 40 characters + the maximum length of the user name. If the buffer parameter is NULL then the routine uses an internal static buffer, the resultant value should be used immediately or copied.

An example of the string created by this routine is

    "1996-12-31 13:45:56.78Z 22301 myname"


make_timestamp_str

    char * make_timestamp_str( char *buffer );
The make_timestamp_str function generates a timestamp string formatted to ISO 8601 / EN28601.

The timestamp is in UTC and is formed using strftime() and then adding hundredths of seconds and timezone offset.

The buffer parameter specifies a data area in which to create this string. If it is provided it should be at least 24 characters long. If the buffer parameter is NULL then the routine uses an internal static buffer, the resultant value should be used immediately or copied. An example of the completed string is;

    "1996-12-31 13:45:56.78Z"


get_my_uname

    char *get_my_uname( void );
The get_my_uname function returns a pointer to an buffer containing the name of the user. This name is the one provided in the passwd structure returned from getpwuid() library call.


Revision note.

As of library version 2.5.0 the make_timestamp_str function produces a string conforming to ISO 8601 / EN28601. Previously the format was YYYY/MM/DD HH:MM:SS:DD which was a little confusing. The new string is one character longer, but does not cause any buffer to be overwritten if they were specified as being at least 24 characters long.