Symantec logo

C++ logging primitives for use by Windows agents

The four C++ logging primitives provided by the agent framework include the two application logging macros:

VCSAG_CONSOLE_LOG_MSG (sev,msgid,flags,fmt,variable_args ... )

VCSAG_LOG_MSG (sev,msgid,flags,fmt,variable_args ... )

and the two debugging macros:

VCSAG_LOGDBG_MSG (dbgsev,flags,fmt,variable_args ... )

VCSAG_RES_LOG_MSG (dbgsev,flags,fmt,variable_args ... )

See C++ agent logging APIs.

Using logging primitives with localized Windows agents

The C++ logging primitives can be used to log Windows agent messages that use wchar arguments. The agents can simply pass in a format string in wchar as well as arguments in wchar to the log macros. The agent framework converts the wchar message to UTF-8 encoding before writing them to log files.The log macros accept a variable number of arguments as input. The arguments can be wchar string, wchar, integer, or floating point values.

Defining UCS-2 encoding when compiling agents

To enable the logging primitives to log messages using UCS-2 encoding (wchar), compile the agent with the "UNICODE" flag defined. Otherwise, compilation fails with errors that indicate a mismatch between the expected argument types and the actual UCS-2 encoded messages sent as arguments.

A sample rule to use to build an agent named MyAgent

.

.

MyAgent.o: MyAgent.C

$(CCPLUS) /FoMyAgent.o -DUNICODE -D_UNICODE -c MyAgent.C

.

.

MyAgent: MyAgent.o

$(CCLINK) /dll /OUT:MyAgent MyAgent.o $(NEED_LIBS)

.

.

where CCPLUS, CCLINK, NEED_LIBS are set as required for the compilation and linking of the agent code.