#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include "vars.h"

void err_mes(char* mes)
{
    FILE *elog;
    if (!err_log) {return;}
    if ((elog=fopen(err_log,"a"))==NULL)
           {
	    printf("ERROR: Can't write to file %s: %s\n",err_log,strerror(errno));
	    exit(-1);
	   }

    fprintf(elog,"%s [%d] %s\n",now(),getpid(),mes);
    fclose (elog);
   
   #ifdef DEBUG_ERR_MES
    fprintf(stderr,"%s [%d] %s\n",now(),getpid(),mes);
   #endif
}
