cppSimpleLogger/logger.h

59 lines
1.1 KiB
C
Raw Normal View History

2020-09-04 23:57:32 +02:00
/**
* @file logger.h
* @brief cppSimpleLogger Header
* @author hendrik schutter
* @date 04.09.2020
*/
2018-10-16 23:34:45 +02:00
#include <time.h>
#include <string.h>
#include <iostream>
2018-10-17 17:03:07 +02:00
#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>
2020-09-04 23:57:32 +02:00
#include <sys/time.h>
#include <math.h>
#include <mutex>
2018-10-17 17:03:07 +02:00
using namespace std;
2020-09-04 23:57:32 +02:00
#define MENU_LINE_SIZE 110 //Size of menu lines
2018-10-17 17:03:07 +02:00
2020-09-04 23:57:32 +02:00
struct sID
{
2018-10-17 17:03:07 +02:00
string description;
string deviceID;
string softwareID;
string hardwareID;
2020-09-04 23:57:32 +02:00
};
2018-10-17 17:03:07 +02:00
2020-09-04 23:57:32 +02:00
class Logger
{
2018-10-17 17:03:07 +02:00
private:
string logPath;
2020-09-04 23:57:32 +02:00
mutex mtxLog;
2018-10-17 17:03:07 +02:00
string getTimestamp();
void writeLog(string s);
string getMacAddress();
2020-09-04 23:57:32 +02:00
string padStringMenu(char cBorder, string text, uint8_t u8LineLenght);
string menuLine(char cBorder, uint8_t u8LineLenght);
2018-10-17 17:03:07 +02:00
2018-10-16 23:34:45 +02:00
public:
2018-10-17 17:03:07 +02:00
Logger(string pLogPath, struct sID id);
2018-10-16 23:34:45 +02:00
~Logger();
2018-10-17 17:03:07 +02:00
void info(string s);
void warning(string s);
void error(string s);
void newLine();
2018-10-16 23:34:45 +02:00
};