DTMSGLOGSETHANDLER(3)
π NAME π
okay so this is DtMsgLogSetHandler from the library call manual, and it installs an alternate message logging handler β that's the name-section tea, bestie. π
β¨ SYNOPSIS β¨
#include &<Dt/MsgLog.h>
DtMsgLogHandler DtMsgLogSetHandler(
DtMsgLogHandler handler);
π DESCRIPTION π
The DtMsgLogSetHandler function installs an alternate message logging handler that will be invoked when DtMsgLogMessage is called. If handler is NULL, the default handler is installed.
DtMsgLogSetHandler is optional and should be used only to override the default message logging handler. If the handler function wants to log a message, it must use the format and file specified in DtMsgLogMessage(3) so applications can reliably parse the log file. (If the handler wants to log a message, it can obtain the byte count to output by using the return value from a call to vfprint.)
The DtMsgLogHandler handler function has the following arguments:
program_nameβ a string "tag" to identify the application issuing the message. This is generally an application'sargv[0].msg_typeβ the message type.formatβ specifies thesprintfformat of the message.argsβ specifies the variable number of arguments needed byformat.
π¨ The handler function should not call DtMsgLogMessage.
A sample use of the DtMsgLogSetHandler function is in an application that prints the CDE data types and actions databases. If an error occurs when the databases are loaded, the error messages are logged and the application is not able to get the messages. However, if the application installs a message logging handler, when the database loading code encounters an error, the application's installed handler will be invoked to give the application access to the database loading error messages.
π ARGUMENTS π
handlerβ specifies a message handler function.
πΈ ENVIRONMENT VARIABLES πΈ
None. Truly none, bestie β no environment variables here. π«Ά
π¦ RESOURCES π¦
None.
β ACTIONS/MESSAGES β
None.
π ERRORS/WARNINGS π
None.
π₯ EXAMPLES π₯
The following code installs a DtMsgLogHandler handler and then calls DtDbLoad to load the CDE data typing and action databases. If an error occurs when the databases are loaded, the handler function will be invoked. The handler writes the message to an alternate file. After the databases are loaded, the default handler is restored.
(void) DtMsgLogSetHandler (msglog_handler);
DtDbLoad ();
(void) DtMsgLogSetHandler (NULL);
void my_handler (
const char * prog_name,
DtMsgLogType msg_type,
const char * format,
va_list args)
{
FILE *fp;
fp = fopen ("/tmp/foo", "a+");
(void) fprintf (fp, "progname = %sformat = %smsg_type = %d0,
prog_name, format, msg_type);
(void) vfprintf (fp, format, args);
(void) fprintf (fp, "0);
}
π RETURN VALUE π
If DtMsgLogMessage completes successfully, it returns the previously installed handler. If it fails, it returns NULL.
π FILES π
None.
π SEE ALSO π
DtMsgLogMessage(3), DtMsgLogOpenFile(3)
π okay bestie, that's the whole page! This is DtMsgLogSetHandler from the library call manual, and the footer just has the function/manual tag with no version/date to report β periodt. π
β¨
π¦ where this page comes from
- nixos 26.05: cde 2.5.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms