root/openwsman/trunk/bindings/openwsman.c

Revision 3127, 1.2 kB (checked in by kkaempf, 7 months ago)

include openwsman.h for the prototypes

Line 
1 #include <wsman-debug.h>
2 #include "openwsman.h"
3 /*-----------------------------------------------------------------*/
4 /* Rbwsman */
5 /* debug (mostly stolen from src/server/wsmand.c) */
6
7 void
8 debug_message_handler (const char *str,
9                        debug_level_e level,
10                        void *user_data)
11 {
12   static int log_pid = 0;
13
14   if (log_pid == 0)
15     log_pid = getpid ();
16 #if 0
17   if (level <= wsmand_options_get_debug_level ()
18       || wsmand_options_get_foreground_debug() > 0 )
19 #endif
20   {
21     struct tm *tm;
22     time_t now;
23     char timestr[128];
24     char *log_msg;
25     int p;
26
27     time (&now);
28     tm = localtime (&now);
29     strftime (timestr, 128, "%b %e %T", tm);
30
31     log_msg = u_strdup_printf ("%s [%d] %s\n",
32                                timestr, log_pid, str);
33     if ( (p = write (STDERR_FILENO, log_msg, strlen (log_msg)) ) < 0  )
34       fprintf(stderr, "Failed writing to log file\n");
35     fsync (STDERR_FILENO);
36
37     u_free (log_msg);
38   }
39 #if 0
40   if ( level <= wsmand_options_get_syslog_level ())
41   {
42     char *log_name = u_strdup_printf( "wsmand[%d]", log_pid );
43
44     openlog( log_name, 0, LOG_DAEMON );
45     syslog( LOG_INFO, "%s", str );
46     closelog();
47     u_free( log_name );
48   }
49 #endif
50 }
51