Пример #1
0
extern void eventlog_step(char const * filename, t_eventlog_level level, char const * module, char const * fmt, ...)
{
    va_list args;
    char        time_string[EVENT_TIME_MAXLEN];
    struct tm * tmnow;
    time_t      now;
    FILE *      fp;
    
    if (!(level&currlevel))
	return;
    if (!eventstrm)
	return;
    
    if (!(fp = fopen(filename, "a")))
	return;
    
    /* get the time before parsing args */
    time(&now);
    if (!(tmnow = localtime(&now)))
	strcpy(time_string,"?");
    else
	strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow);
    
    if (!module)
    {
	fprintf(fp,"%s [error] eventlog_step: got NULL module\n",time_string);
	fclose(fp);
	return;
    }
    if (!fmt)
    {
	fprintf(fp,"%s [error] eventlog_step: got NULL fmt\n",time_string);
	fclose(fp);
	return;
    }
    
    fprintf(fp,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
    va_start(args,fmt);
#ifdef HAVE_VPRINTF
    vfprintf(fp,fmt,args);
#else
# if HAVE__DOPRNT
    _doprnt(fmt,args,fp);
# else
    fprintf(fp,"sorry, vfprintf() and _doprnt() are not available on this system");
# endif
#endif
    va_end(args);
    fprintf(fp,"\n");
    fclose(fp);
}
Пример #2
0
extern void eventlog_step(char const * filename, t_eventlog_level level, char const * module, char const * fmt, ...)
{
    std::va_list args;
    char        time_string[EVENT_TIME_MAXLEN];
    struct std::tm * tmnow;
    std::time_t      now;
    std::FILE *      fp;

    if (!(level&currlevel))
	return;
    if (!eventstrm)
	return;

    if (!(fp = std::fopen(filename, "a")))
	return;

    /* get the time before parsing args */
    std::time(&now);
    if (!(tmnow = std::localtime(&now)))
	std::strcpy(time_string,"?");
    else
	std::strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow);

    if (!module)
    {
	    std::fprintf(fp,"%s [error] eventlog_step: got NULL module\n",time_string);
	std::fclose(fp);
	return;
    }
    if (!fmt)
    {
	    std::fprintf(fp,"%s [error] eventlog_step: got NULL fmt\n",time_string);
	std::fclose(fp);
	return;
    }

    std::fprintf(fp,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
    va_start(args,fmt);
    std::vfprintf(fp,fmt,args);
    va_end(args);
    std::fprintf(fp,"\n");
    std::fclose(fp);
}
Пример #3
0
extern void eventlog(t_eventlog_level level, char const * module, char const * fmt, ...)
{
    std::va_list     args;
    char        time_string[EVENT_TIME_MAXLEN];
    struct std::tm * tmnow;
    std::time_t      now;

    if (!(level&currlevel))
	return;
    if (!eventstrm)
	return;

    /* get the time before parsing args */
    std::time(&now);
    if (!(tmnow = std::localtime(&now)))
	std::strcpy(time_string,"?");
    else
	std::strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow);

    if (!module)
    {
	    std::fprintf(eventstrm,"%s [error] eventlog: got NULL module\n",time_string);
#ifdef WIN32_GUI
    if (eventlog_level_gui&currlevel)
	    gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL module\n",time_string);
#endif
	std::fflush(eventstrm);
	return;
    }

    if (!fmt)
    {
	    std::fprintf(eventstrm,"%s [error] eventlog: got NULL fmt\n",time_string);
#ifdef WIN32_GUI
    if (eventlog_level_gui&currlevel)
	    gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL fmt\n",time_string);
#endif
	std::fflush(eventstrm);
	return;
    }

    std::fprintf(eventstrm,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
#ifdef WIN32_GUI
    if (eventlog_level_gui&currlevel)
	    gui_lprintf(level,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
#endif

    va_start(args,fmt);

    std::vfprintf(eventstrm,fmt,args);
#ifdef WIN32_GUI
    if (eventlog_level_gui&currlevel)
      gui_lvprintf(level,fmt,args);
#endif
    va_end(args);
    std::fprintf(eventstrm,"\n");
#ifdef WIN32_GUI
    if (eventlog_level_gui&currlevel)
      gui_lprintf(level,"\n");
#endif

    if (eventlog_debugmode) {
	    std::printf("%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
    	va_start(args,fmt);
	std::vprintf(fmt,args);
    	va_end(args);
	std::printf("\n");
	std::fflush(stdout);
    }
    std::fflush(eventstrm);
}
Пример #4
0
extern void eventlog(t_eventlog_level level, char const * module, char const * fmt, ...)
#endif
{
    va_list     args;
    char        time_string[EVENT_TIME_MAXLEN];
    struct tm * tmnow;
    time_t      now;
    
    if (!(level&currlevel))
	return;
    if (!eventstrm)
	return;
    
    /* get the time before parsing args */
    time(&now);
    if (!(tmnow = localtime(&now)))
	strcpy(time_string,"?");
    else
	strftime(time_string,EVENT_TIME_MAXLEN,EVENT_TIME_FORMAT,tmnow);
    
    if (!module)
    {
	fprintf(eventstrm,"%s [error] eventlog: got NULL module\n",time_string);
#ifdef WIN32_GUI
        gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL module\n",time_string);
#endif
	fflush(eventstrm);
	return;
    }

    if (!fmt)
    {
	fprintf(eventstrm,"%s [error] eventlog: got NULL fmt\n",time_string);
#ifdef WIN32_GUI
        gui_lprintf(eventlog_level_error,"%s [error] eventlog: got NULL fmt\n",time_string);
#endif
	fflush(eventstrm);
	return;
    }
    
    fprintf(eventstrm,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
#ifdef WIN32_GUI
    gui_lprintf(level,"%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
#endif

    va_start(args,fmt);

#ifdef HAVE_VPRINTF
    vfprintf(eventstrm,fmt,args);
#ifdef WIN32_GUI
    gui_lvprintf(level,fmt,args);
#endif
#else
# if HAVE__DOPRNT
    _doprnt(fmt,args,eventstrm);
# else
    fprintf(eventstrm,"sorry, vfprintf() and _doprnt() are not available on this system");
# endif
#endif
    va_end(args);
    fprintf(eventstrm,"\n");
#ifdef WIN32_GUI
    gui_lprintf(level,"\n");
#endif

    if (eventlog_debugmode) {
    	printf("%s [%s] %s: ",time_string,eventlog_get_levelname_str(level),module);
    	va_start(args,fmt);
#ifdef HAVE_VPRINTF
    	vprintf(fmt,args);
#else
# if HAVE__DOPRNT
    	_doprnt(fmt,args,stdout);
# else
    	printf("sorry, vfprintf() and _doprnt() are not available on this system");
# endif
#endif
    	va_end(args);
    	printf("\n");
        fflush(stdout);
    }
    fflush(eventstrm);
}