reHDD/include/logger/logger.h

79 lines
1.5 KiB
C
Raw Normal View History

2020-09-07 17:23:15 +02:00
/**
* @file logger.h
* @brief cppSimpleLogger Header
* @author hendrik schutter
* @date 04.09.2020
*/
#ifndef LOGGER_H_
#define LOGGER_H_
#include <time.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <net/if.h>
#include <unistd.h>
#include <sys/time.h>
#include <math.h>
#include <mutex>
using namespace std;
2024-04-24 22:31:09 +02:00
#define MENU_LINE_SIZE 110 // Size of menu lines
2020-09-07 17:23:15 +02:00
#ifndef LOG_PATH
2024-04-24 22:31:09 +02:00
// #define LOG_PATH "./test.txt"
2020-09-07 17:23:15 +02:00
#endif
#ifndef DESCRIPTION
2024-04-24 22:31:09 +02:00
#define DESCRIPTION "Software-Name - Copyright Company 2020" // use your values here
2020-09-07 17:23:15 +02:00
#endif
#ifndef DEVICE_ID
2024-04-24 22:31:09 +02:00
#define DEVICE_ID "Device-Name" // use your values here
2020-09-07 17:23:15 +02:00
#endif
#ifndef SOFTWARE_VERSION
2024-04-24 22:31:09 +02:00
#define SOFTWARE_VERSION "0.1.1.8" // use your values here
2020-09-07 17:23:15 +02:00
#endif
#ifndef HARDWARE_VERSION
2024-04-24 22:31:09 +02:00
#define HARDWARE_VERSION "7.77.9" // use your values here
2020-09-07 17:23:15 +02:00
#endif
class Logger
{
private:
string logPath;
mutex mtxLog;
static bool instanceFlag;
static Logger *single;
string getTimestamp();
void writeLog(string s);
string getMacAddress();
string padStringMenu(char cBorder, string text, uint8_t u8LineLenght);
string menuLine(char cBorder, uint8_t u8LineLenght);
Logger();
~Logger();
public:
void info(string s);
void warning(string s);
void error(string s);
void newLine();
2024-04-24 22:31:09 +02:00
static Logger *logThis();
2020-09-07 17:23:15 +02:00
};
2024-04-24 22:31:09 +02:00
#endif // LOGGER_H_