### Setting Up for Serviceability

Serviceability standardizes the server messages displayed or logged. It acts on a set of standard message catalogs and application-specific catalogs generated from the sams utility. Some of the obvious advantages the serviceability facility gives servers over using the standard C library routines such as printf( ) and fprintf( ) include the following:

· Messages do not need to be hard-coded into applications

· Message routing can be better controlled

The following routine shows how a server can report a status code returned from an API routine:

void
print_server_error(
char *caller, /* Routine that received the error. */
error_status_t status) /* Status we want to print the message for. */
{
dce_error_string_t error_string;
int print_status;
dce_error_inq_text(status, error_string, &print_status);
dce_svc_printf(SERVER_ERROR_MSG, caller, error_string);
}

The dce_error_inq_text( ) routine looks up the status number in a standard table and returns a string of text that describes the error status. The serviceability routine dce_svc_printf( ) then displays the message, logs it to one or more files, or both.

The following code shows some typical tasks when setting up the server for serviceability:

/* The following calls set up default routing of serviceability */
/* messages. */
for (i = 0, route_error = FALSE; (i < MAX_DEFAULT_ROUTES)
&& (!route_error); i++)
{
printf("Setting default route %s ...\en", default_routes[i]);
dce_svc_routing(default_routes[i], &status);
if (status != svc_s_ok)
{
print_server_error("dce_svc_routing(default_routes[i])", status);
}
}
/* Get serviceability handle... */
smp_svc_handle = dce_svc_register(smp_svc_table,
(idl_char*)"smp", &status);
if (status != error_status_ok)
{
print_server_error("dce_svc_register()", status);
exit(1); }
/* Set the default serviceability debug level and route... */
dce_svc_debug_routing(default_debug_route, &status);
/* Set up in-memory serviceability message table... */
dce_msg_define_msg_table(smp__table,
sizeof smp__table / sizeof smp__table[0],
&status);
if (status != error_status_ok)
{
print_server_error("dce_msg_define_msg_table()", status);
exit(1);
}
dce_svc_printf(SIGN_ON_MSG);
.
.
.
DCE_SVC_DEBUG((smp_svc_handle,
smp_s_server,
svc_c_debug4,
"Calling dce_server_sec_begin()");

###