removed logger
This commit is contained in:
parent
cbf4f6bdcd
commit
4d17a14835
2 changed files with 0 additions and 75 deletions
|
|
@ -1,32 +0,0 @@
|
||||||
#include "logging.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
FILE* log_file = NULL;
|
|
||||||
|
|
||||||
void init_logger() {
|
|
||||||
log_file = fopen("tetris.log", "w");
|
|
||||||
if (log_file == NULL) {
|
|
||||||
fprintf(stderr, "Error: Could not open log file\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t now = time(0);
|
|
||||||
char* time_str = ctime(&now);
|
|
||||||
time_str[strlen(time_str) - 1] = '\0';
|
|
||||||
|
|
||||||
fprintf(log_file, "[INIT] %s: Logger initialized\n", time_str);
|
|
||||||
fflush(log_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void close_logger() {
|
|
||||||
if (log_file != NULL) {
|
|
||||||
time_t now = time(0);
|
|
||||||
char* time_str = ctime(&now);
|
|
||||||
time_str[strlen(time_str) - 1] = '\0';
|
|
||||||
|
|
||||||
fprintf(log_file, "[CLOSE] %s: Logger closed\n", time_str);
|
|
||||||
fclose(log_file);
|
|
||||||
log_file = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
#ifndef LOGGING_H
|
|
||||||
#define LOGGING_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// Макрос для логгирования начала функции
|
|
||||||
#define LOG_FUNCTION_START(func_name, ...) \
|
|
||||||
do { \
|
|
||||||
time_t now = time(0); \
|
|
||||||
char* time_str = ctime(&now); \
|
|
||||||
time_str[strlen(time_str) - 1] = '\0'; \
|
|
||||||
fprintf(log_file, "[START] %s: %s", time_str, func_name); \
|
|
||||||
if (sizeof(#__VA_ARGS__) > 1) { \
|
|
||||||
fprintf(log_file, " - " __VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
fprintf(log_file, "\n"); \
|
|
||||||
fflush(log_file); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
// Макрос для логгирования конца функции
|
|
||||||
#define LOG_FUNCTION_END(func_name, ...) \
|
|
||||||
do { \
|
|
||||||
time_t now = time(0); \
|
|
||||||
char* time_str = ctime(&now); \
|
|
||||||
time_str[strlen(time_str) - 1] = '\0'; \
|
|
||||||
fprintf(log_file, "[END] %s: %s", time_str, func_name); \
|
|
||||||
if (sizeof(#__VA_ARGS__) > 1) { \
|
|
||||||
fprintf(log_file, " - " __VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
fprintf(log_file, "\n"); \
|
|
||||||
fflush(log_file); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
// Инициализация логгера
|
|
||||||
void init_logger();
|
|
||||||
// Закрытие логгера
|
|
||||||
void close_logger();
|
|
||||||
// Глобальная переменная для файла лога
|
|
||||||
extern FILE* log_file;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue