added logging basics
This commit is contained in:
80
include/logger/logger.h
Normal file
80
include/logger/logger.h
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @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;
|
||||
|
||||
#define MENU_LINE_SIZE 110 //Size of menu lines
|
||||
|
||||
#ifndef LOG_PATH
|
||||
//#define LOG_PATH "./test.txt"
|
||||
#endif
|
||||
|
||||
#ifndef DESCRIPTION
|
||||
#define DESCRIPTION "Software-Name - Copyright Company 2020" //use your values here
|
||||
#endif
|
||||
|
||||
#ifndef DEVICE_ID
|
||||
#define DEVICE_ID "Device-Name" //use your values here
|
||||
#endif
|
||||
|
||||
#ifndef SOFTWARE_VERSION
|
||||
#define SOFTWARE_VERSION "0.1.1.8" //use your values here
|
||||
#endif
|
||||
|
||||
#ifndef HARDWARE_VERSION
|
||||
#define HARDWARE_VERSION "7.77.9" //use your values here
|
||||
#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();
|
||||
|
||||
static Logger* logThis();
|
||||
};
|
||||
|
||||
#endif // LOGGER_H_
|
@ -18,6 +18,13 @@
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
// Logger Settings
|
||||
#define LOG_PATH "./reHDD.log"
|
||||
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2020"
|
||||
#define DEVICE_ID "generic"
|
||||
#define SOFTWARE_VERSION "alpha"
|
||||
#define HARDWARE_VERSION "generic"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
@ -43,7 +50,9 @@ using namespace std;
|
||||
#include "shred/shred.h"
|
||||
#include "delete.h"
|
||||
#include "tui.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
extern Logger* logging;
|
||||
|
||||
template <typename T, typename I> T* iterator_to_pointer(I i)
|
||||
{
|
||||
@ -56,10 +65,12 @@ protected:
|
||||
|
||||
public:
|
||||
reHDD(void);
|
||||
void app_logic();
|
||||
static void app_logic();
|
||||
|
||||
private:
|
||||
|
||||
//static Logger* logging;
|
||||
|
||||
static void searchDrives(vector <Drive>* pvecDrives);
|
||||
static void printDrives(vector <Drive>* pvecDrives);
|
||||
static void filterIgnoredDrives(vector <Drive>* pvecDrives);
|
||||
@ -76,4 +87,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // REHDD_H_
|
||||
#endif // REHDD_H_
|
||||
|
Reference in New Issue
Block a user