Added Logger

This commit is contained in:
Bazsalanszky 2019-10-16 14:02:59 +02:00
parent 0247560a06
commit 8ddfc5fbd0
Signed by: Bazsalanszky
GPG key ID: 0998CF5510B134D9
2 changed files with 39 additions and 2 deletions

View file

@ -74,3 +74,34 @@ void md5(char *string, char outputBuffer[33]){
} }
outputBuffer[64] = 0; 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);
}
}

View file

@ -8,6 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#include <ws2tcpip.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); char* map_getValue(map m[],int len, char* key);
//Debug-hoz hasznos
void map_dump(map m[],int len);
void md5(char *string, char outputBuffer[33]); void md5(char *string, char outputBuffer[33]);
void logger_log(const char* _Format, ...);