/****** uti/sge_log/sge_do_log() *********************************************** * NAME * sge_do_log() -- Write message to log file * * SYNOPSIS * static void sge_do_log(int aLevel, const char *aMessage, const char * * FUNCTION * ??? * * INPUTS * int aLevel - log level * const char *aMessage - log message * * RESULT * void - none * * NOTES * MT-NOTE: sge_do_log() is MT safe. * *******************************************************************************/ static void sge_do_log(u_long32 me, const char* progname, const char* unqualified_hostname, int aLevel, const char *aMessage) { int fd; if (me == QMASTER || me == EXECD || me == SCHEDD || me == SHADOWD) { if ((fd = SGE_OPEN3(log_state_get_log_file(), O_WRONLY | O_APPEND | O_CREAT, 0666)) >= 0) { char msg2log[4*MAX_STRING_SIZE]; dstring msg; int len; sge_dstring_init(&msg, msg2log, sizeof(msg2log)); append_time((time_t)sge_get_gmt(), &msg, false); sge_dstring_sprintf_append(&msg, "|%6.6s|%s|%c|%s\n", progname, unqualified_hostname, aLevel, aMessage); len = strlen(msg2log); if (write(fd, msg2log, len) != len) { /* we are in error logging here - the only chance to log this problem * might be to write it to stderr */ fprintf(stderr, "can't log to file %s: %s\n", log_state_get_log_file(), sge_strerror(errno, &msg)); } close(fd); } } return; } /* sge_do_log() */
/****** uti/sge_log/sge_do_log() *********************************************** * NAME * sge_do_log() -- Write message to log file * * SYNOPSIS * static void sge_do_log(int aLevel, const char *aMessage, const char * * FUNCTION * ??? * * INPUTS * int aLevel - log level * const char *aMessage - log message * * RESULT * void - none * * NOTES * MT-NOTE: sge_do_log() is MT safe. * *******************************************************************************/ static void sge_do_log(u_long32 me, const char* progname, const char* unqualified_hostname, int aLevel, const char *aMessage) { int fd; if (me == QMASTER || me == EXECD || me == SCHEDD || me == SHADOWD) { if ((fd = SGE_OPEN3(log_state_get_log_file(), O_WRONLY | O_APPEND | O_CREAT, 0666)) >= 0) { char msg2log[4*MAX_STRING_SIZE]; dstring msg; sge_dstring_init(&msg, msg2log, sizeof(msg2log)); append_time((time_t)sge_get_gmt(), &msg, false); sge_dstring_sprintf_append(&msg, "|%6.6s|%s|%c|%s\n", progname, unqualified_hostname, aLevel, aMessage); write(fd, msg2log, strlen(msg2log)); close(fd); } } return; } /* sge_do_log() */