Implement logger functionality and signal handling: add Logger structure with mutex, logging functions, and handle SIGINT in utils.
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "users.h"
|
||||
#include "utils.h"
|
||||
#include <string.h>
|
||||
#include <libpq-fe.h>
|
||||
|
||||
int loadListFromCSV(char* _filename, list_t * _list);
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef __LOGGER_H__
|
||||
#define __LOGGER_H__
|
||||
|
||||
#include "main.h"
|
||||
#include "rfid_handler.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t lock;
|
||||
FILE *f_log;
|
||||
} Logger;
|
||||
|
||||
Logger *initLogger(const char *_filename);
|
||||
int logErrorEvent(Logger *_logger, const char *_message);
|
||||
int logWarningEvent(Logger *_logger, const char *_message);
|
||||
int logHardwareEvent(Logger *_logger, const char *_event_origin, const char *_message);
|
||||
int logInfoEvent(Logger *_logger, const char *_message);
|
||||
int endLogger(Logger *_logger);
|
||||
|
||||
#endif
|
||||
+21
-3
@@ -1,3 +1,23 @@
|
||||
/**
|
||||
* @file main.h
|
||||
* @brief Main header file for the application.
|
||||
*
|
||||
* This header includes all necessary standard and project-specific headers,
|
||||
* defines basic macros and types, and declares the main entry point of the program.
|
||||
*
|
||||
* Included headers:
|
||||
* - Standard C libraries (stdio, stdlib, stdint, time, unistd, pthread, ncurses, fcntl, errno, termios, string, signal)
|
||||
* - Project-specific modules (utils, logger, users, tui, rfid_handler, file_handler)
|
||||
*
|
||||
* Macros:
|
||||
* - TRUE, FALSE: Boolean values for logic operations.
|
||||
* - BYTE: Unsigned 8-bit integer type alias.
|
||||
* - MIN_X_TERMINAL_SIZE, MIN_Y_TERMINAL_SIZE: Minimum terminal dimensions for UI.
|
||||
*
|
||||
* Function Declarations:
|
||||
* - int main(int argc, char const **argv): Program entry point.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,7 +34,6 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
@@ -34,9 +53,8 @@
|
||||
#define MIN_X_TERMINAL_SIZE 50
|
||||
#define MIN_Y_TERMINAL_SIZE 20
|
||||
|
||||
void handle_sigint(int sig);
|
||||
#define JOURNAL_FILENAME "lighttam_journal"
|
||||
|
||||
int main(int argc, char const **argv);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -7,4 +7,5 @@ void printTimeInString(time_t _input, char * _output);
|
||||
|
||||
void printDateAndTimeInString(time_t _input, char * _output);
|
||||
|
||||
void handle_sigint(int sig);
|
||||
#endif
|
||||
Reference in New Issue
Block a user