| iMatix home page|
| << | < | > | >>
Creates log files, and writes data to the log files. Can handle multiple log files in parallel; each open log file is managed by one thread. Sends errors to the operator console agent.
To use, call smtlog init(). This does not create any threads. Create an unnamed thread using the thread_create() function. Send an OPEN or APPEND event to create the log file and PUT events to write to the log file. Finally, send a CLOSE event to close the log file and terminate the log file thread. SMTLOG does not reply - errors are sent to the console, not the requesting program. It supports these methods:
Example of initialising SMTLOG:
/* Static data */ static QID logq; /* Logging agent event queue */ /* In agent initialisation code */ THREAD *thread; /* Handle to various threads */ /* Ensure that logging agent is running, else start it */ smtlog init (); if ((thread = thread create (SMT_LOGGING, "")) != NULL) logq = thread-> queue-> qid; /* Get logging queue id */ else return (-1);
If the specified log file already exists, renames it to a file whose name consists of the first letter of the log file name, followed by the date in 7 positions (YYYYDDD). If that file name already exists, generates a unique filename. Takes the event body to supply the log file name; if the event body is empty, uses the thread name instead. If the log file name is empty ("") or the 4-letter string "NULL", nothing is done.
Creates a new, empty log file. Takes the event body to supply the log file name; if the event body is empty, uses the thread name instead. If the log file name is "" or "NULL", no file is created, and SMTLOG discards all output.
Opens an existing log file for additional output. If the log file does not already exist, acts like OPEN. Takes the event body to supply the log file name; if the event body is empty, uses the thread name instead.
Takes the event body as a string, prefixes the date and time, and writes it to the log file.
Disables time-stamping of the logged data. Use this when you do not want the default SMTLOG time-stamping.
Enables time-stamping of the logged data.
Closes the log file and destroys the thread used to manage it. You normally send this event when you end your program.
The SMTECHO agent shows an example of using the Logging agent.
The hypertext view of SMTLOG's dialog and source code may help to understand how SMTLOG works.
|| << | < | > | >>||Copyright © 1996-99 iMatix Corporation|