Added Logger
This commit is contained in:
parent
0247560a06
commit
8ddfc5fbd0
2 changed files with 39 additions and 2 deletions
33
utility.c
33
utility.c
|
@ -73,4 +73,35 @@ void md5(char *string, char outputBuffer[33]){
|
|||
sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
|
||||
}
|
||||
outputBuffer[64] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void logger_log(const char* _Format, ...){
|
||||
FILE * fp;
|
||||
fp = fopen("log.txt","a");
|
||||
time_t timer;
|
||||
char buf[26];
|
||||
struct tm* tm_info;
|
||||
|
||||
time(&timer);
|
||||
tm_info = localtime(&timer);
|
||||
|
||||
strftime(buf, 26, "%Y.%m.%d. %H:%M:%S", tm_info);
|
||||
char string[513];
|
||||
printf("[%s]\t",buf);
|
||||
fprintf(fp,"[%s]\t");
|
||||
va_list args;
|
||||
va_start (args, _Format);
|
||||
vprintf(_Format,args);
|
||||
vfprintf(fp,_Format,args);
|
||||
va_end(args);
|
||||
fprintf(fp,"\n");
|
||||
printf(stdout,"\n");
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void map_dump(map *m, int len) {
|
||||
for (int i = 0; i <len ; ++i) {
|
||||
printf("%s %s\n",m[i].key,m[i].value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
@ -29,4 +30,9 @@ bool map_isFound(map m[],int len, char* key);
|
|||
|
||||
char* map_getValue(map m[],int len, char* key);
|
||||
|
||||
void md5(char *string, char outputBuffer[33]);
|
||||
//Debug-hoz hasznos
|
||||
void map_dump(map m[],int len);
|
||||
|
||||
void md5(char *string, char outputBuffer[33]);
|
||||
|
||||
void logger_log(const char* _Format, ...);
|
Loading…
Reference in a new issue