Diego Romero Gil
Publicado por adalberto (1 intervención) el 11/09/2008 02:13:48
int grabarEnLog(char *nomproc,pid_t pid,pthread_t idhilo,char *tipo,char *dato)
{
char lineaArch[400];
FILE *arch;
time_t tiempo;
char cad[80];
struct tm *tmPtr;
if(arch=fopen("log.txt","at+"))==NIL)
if(arch=fopen("log.txt","wt"))
return -1;
tiempo = time(NULL);
tmPtr = localtime(&tiempo);
strftime(cad, 80, "%H:%M.%S, %A de %B de %Y", tmPtr);
sprintf(lineaArch,"%s %s %d %d:%s:%s ",cad,nomproc,pid,idhilo,tipo,dato);
if ((fwrite(lineaArch,sizeof(lineaArch),1,arch))<sizeof(lineaArch))
return -1;
return 0;
}
{
char lineaArch[400];
FILE *arch;
time_t tiempo;
char cad[80];
struct tm *tmPtr;
if(arch=fopen("log.txt","at+"))==NIL)
if(arch=fopen("log.txt","wt"))
return -1;
tiempo = time(NULL);
tmPtr = localtime(&tiempo);
strftime(cad, 80, "%H:%M.%S, %A de %B de %Y", tmPtr);
sprintf(lineaArch,"%s %s %d %d:%s:%s ",cad,nomproc,pid,idhilo,tipo,dato);
if ((fwrite(lineaArch,sizeof(lineaArch),1,arch))<sizeof(lineaArch))
return -1;
return 0;
}
Valora esta pregunta


0