update view_log
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,22 @@
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
@@ -22,14 +38,6 @@
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
@@ -46,10 +54,6 @@
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
|
||||
"RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
|
||||
@@ -70,11 +74,24 @@
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 2,
|
||||
"SelectedChildIndex": 3,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"DocumentIndex": 4,
|
||||
"Title": "settings.h",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h",
|
||||
"RelativeDocumentMoniker": "settings.h",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h",
|
||||
"RelativeToolTip": "settings.h",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA8AAAAcAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||
"WhenOpened": "2024-03-09T13:50:21.91Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 6,
|
||||
"Title": "connect.h",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h",
|
||||
"RelativeDocumentMoniker": "connect.h",
|
||||
@@ -82,12 +99,11 @@
|
||||
"RelativeToolTip": "connect.h",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAABPAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||
"WhenOpened": "2024-03-09T12:32:01.859Z",
|
||||
"EditorCaption": ""
|
||||
"WhenOpened": "2024-03-09T12:32:01.859Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 9,
|
||||
"DocumentIndex": 11,
|
||||
"Title": "check_dir.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp",
|
||||
"RelativeDocumentMoniker": "check_dir.cpp",
|
||||
@@ -105,26 +121,27 @@
|
||||
"RelativeDocumentMoniker": "log.h",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h",
|
||||
"RelativeToolTip": "log.h",
|
||||
"ViewState": "AQIAAGYAAAAAAAAAAAAYwJMAAAAkAAAA",
|
||||
"ViewState": "AQIAAGAAAAAAAAAAAAAAAIIAAACFAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
|
||||
"WhenOpened": "2024-02-25T09:02:55.874Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 5,
|
||||
"DocumentIndex": 3,
|
||||
"Title": "log.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp",
|
||||
"RelativeDocumentMoniker": "log.cpp",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.cpp",
|
||||
"RelativeToolTip": "log.cpp",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAeAAAA",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAB8AAAAFAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2024-02-25T09:08:59.07Z"
|
||||
"WhenOpened": "2024-02-25T09:08:59.07Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 12,
|
||||
"DocumentIndex": 13,
|
||||
"Title": "local_com.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp",
|
||||
"RelativeDocumentMoniker": "local_com.cpp",
|
||||
@@ -136,19 +153,20 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 11,
|
||||
"DocumentIndex": 5,
|
||||
"Title": "settings.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp",
|
||||
"RelativeDocumentMoniker": "settings.cpp",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp",
|
||||
"RelativeToolTip": "settings.cpp",
|
||||
"ViewState": "AQIAAAYAAAAAAAAAAAAAABkAAAAUAAAA",
|
||||
"ViewState": "AQIAALQAAAAAAAAAAAAAANEAAAAAAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2024-01-28T20:40:06.264Z"
|
||||
"WhenOpened": "2024-01-28T20:40:06.264Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 4,
|
||||
"DocumentIndex": 8,
|
||||
"Title": "thread_ctrl.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp",
|
||||
"RelativeDocumentMoniker": "thread_ctrl.cpp",
|
||||
@@ -160,19 +178,20 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 6,
|
||||
"DocumentIndex": 2,
|
||||
"Title": "client_backend.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp",
|
||||
"RelativeDocumentMoniker": "client_backend.cpp",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp",
|
||||
"RelativeToolTip": "client_backend.cpp",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAACwAAAAiAAAA",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAAQAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2024-01-28T20:40:06.279Z"
|
||||
"WhenOpened": "2024-01-28T20:40:06.279Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 8,
|
||||
"DocumentIndex": 10,
|
||||
"Title": "scan.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp",
|
||||
"RelativeDocumentMoniker": "scan.cpp",
|
||||
@@ -184,7 +203,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 7,
|
||||
"DocumentIndex": 9,
|
||||
"Title": "update.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp",
|
||||
"RelativeDocumentMoniker": "update.cpp",
|
||||
@@ -196,7 +215,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 10,
|
||||
"DocumentIndex": 12,
|
||||
"Title": "local_schedule.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp",
|
||||
"RelativeDocumentMoniker": "local_schedule.cpp",
|
||||
@@ -208,7 +227,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 14,
|
||||
"DocumentIndex": 15,
|
||||
"Title": "scan.h",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h",
|
||||
"RelativeDocumentMoniker": "scan.h",
|
||||
@@ -220,7 +239,7 @@
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 13,
|
||||
"DocumentIndex": 14,
|
||||
"Title": "queue _ctrl.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp",
|
||||
"RelativeDocumentMoniker": "queue _ctrl.cpp",
|
||||
@@ -238,14 +257,14 @@
|
||||
"RelativeDocumentMoniker": "connect.cpp",
|
||||
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp",
|
||||
"RelativeToolTip": "connect.cpp",
|
||||
"ViewState": "AQIAAJUAAAAAAAAAAAAQwLsAAAAaAAAA",
|
||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAABkAAAADAAAA",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
|
||||
"WhenOpened": "2024-01-28T20:40:06.315Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 3,
|
||||
"DocumentIndex": 7,
|
||||
"Title": "virus_ctrl.cpp",
|
||||
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp",
|
||||
"RelativeDocumentMoniker": "virus_ctrl.cpp",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,6 @@
|
||||
#ifndef LOG_CPP
|
||||
#define LOG_CPP
|
||||
#include "log.h"
|
||||
|
||||
std::string get_loglevel(LOGLEVEL level) {
|
||||
switch (level) {
|
||||
case LOGLEVEL::INFO:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
@@ -9,8 +10,6 @@
|
||||
#include "well_known.h"
|
||||
#include "settings.h"
|
||||
#include "security.h"
|
||||
int srv_timeout = 0;
|
||||
int timeout_reset = 0;
|
||||
enum class LOGLEVEL {
|
||||
INFO,
|
||||
WARN,
|
||||
@@ -28,7 +27,7 @@ std::string get_loglevel(LOGLEVEL level);
|
||||
|
||||
template <typename... Args>
|
||||
void log(LOGLEVEL level, const std::string& message, Args&&... args) {
|
||||
timeout_reset++;
|
||||
log_timeout_reset_set(log_timeout_reset_get()+1);
|
||||
std::string prefix = get_loglevel(level);
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm tm;
|
||||
@@ -96,7 +95,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) {
|
||||
fclose(fp);
|
||||
}
|
||||
//write to server log file only if we werent able to send the logs directly. this file will store them until we can upload them
|
||||
if (fopen_s(&fp, SRV_LOGFILE, "a") == 0 && srv_timout>=5) { //if server already did not respon over 5 times, we add it to the log file
|
||||
if (fopen_s(&fp, SRV_LOGFILE, "a") == 0 && log_timeout_get() >= 5) { //if server already did not respon over 5 times, we add it to the log file
|
||||
fprintf_s(fp, "%s\n", to_srv_string.c_str());
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -105,7 +104,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) {
|
||||
//build up the log string: loglevel&logtext&machineid&date
|
||||
//to_srv_string=includes the log message
|
||||
//we now need to build up the request string and append the machineid
|
||||
if (level!=LOGLEVEL::INFO_NOSEND && level!=LOGLEVEL::WARN_NOSEND && level!=LOGLEVEL::ERR_NOSEND && level!=LOGLEVEL::PANIC_NOSEND && srv_timeout<5) {
|
||||
if (level!=LOGLEVEL::INFO_NOSEND && level!=LOGLEVEL::WARN_NOSEND && level!=LOGLEVEL::ERR_NOSEND && level!=LOGLEVEL::PANIC_NOSEND && log_timeout_get()<5) {
|
||||
char* url = new char[3000];
|
||||
int res = 0;
|
||||
if (get_setting("server:server_url", url) == 0 or strcmp(url, "nan") == 0) {
|
||||
@@ -115,22 +114,24 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) {
|
||||
strcat_s(url, 3000, get_machineid(SECRETS));
|
||||
strcat_s(url, 3000, "&apikey=");
|
||||
strcat_s(url, 3000, get_apikey(SECRETS));
|
||||
res=fast_send(url, get_setting("communication:unsafe_tls");
|
||||
res=fast_send(url, get_setting("communication:unsafe_tls"));
|
||||
if (res != 0) {
|
||||
//we know that the server might be down, so we will increment the timeout counter
|
||||
srv_timeout++;
|
||||
log_timeout_set(log_timeout_get() + 1);
|
||||
}
|
||||
//we might not want to log an error occuring here because it will create a loop
|
||||
delete[] url;
|
||||
}
|
||||
else {
|
||||
delete[] url;
|
||||
return;
|
||||
}
|
||||
}//else we do not send the log to the server
|
||||
if(timeout_reset>100){ //after 100 log entrys, we cna try again to reach out ot the server.
|
||||
timeout_reset=0;
|
||||
srv_timeout=0;
|
||||
if (log_timeout_reset_get() > 100)
|
||||
{
|
||||
log_timeout_reset_set(0);
|
||||
log_timeout_set(0);
|
||||
}
|
||||
//!!!i disabled this temporarely, because it does not really work and as long as the client is in lan the other code works anyway
|
||||
if(log_timeout_reset_get()>100 && 1==0) { //after 100 log entrys, we cna try again to reach out ot the server.
|
||||
log_timeout_reset_set(0);
|
||||
log_timeout_set(0);
|
||||
//try to upload the server_log file, where we stored the logs which we could not upload.
|
||||
char* url = new char[3000];
|
||||
int res = 0;
|
||||
@@ -142,7 +143,7 @@ void log(LOGLEVEL level, const std::string& message, Args&&... args) {
|
||||
res=upload_to_srv(SRV_LOGFILE, url, get_setting("communication:unsafe_tls"));
|
||||
if (res != 0) {
|
||||
//we know that the server might be down, so we will increment the timeout counter
|
||||
srv_timeout++;
|
||||
log_timeout_set(log_timeout_get() + 1);
|
||||
}
|
||||
else {
|
||||
//remove the logfile
|
||||
|
||||
@@ -11,6 +11,8 @@ char included_folders[100][300];
|
||||
int included_folders_size = 0;
|
||||
bool setting_rtp_folder_scan_status = 1; //0=off, 1=on
|
||||
bool setting_communication_unsafe_tls = 0; //0=do not allow communication via unsfae, slef signed certs, 1=allwo communication via unsafe, self signed certs
|
||||
int srv_log_timeout = 0;
|
||||
int log_timeout_reset = 0;
|
||||
void load_included_folders();
|
||||
void load_excluded_folders();
|
||||
int load_settings() {
|
||||
@@ -205,4 +207,17 @@ void print_inclusuions() {
|
||||
log(LOGLEVEL::INFO, "[print_exclusions()]: Excluded folder: ", exluded_folders[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int log_timeout_get() {
|
||||
return srv_log_timeout;
|
||||
}
|
||||
void log_timeout_set(int timeout) {
|
||||
srv_log_timeout = timeout;
|
||||
}
|
||||
void log_timeout_reset_set(int timeout) {
|
||||
log_timeout_reset = timeout;
|
||||
}
|
||||
int log_timeout_reset_get() {
|
||||
return log_timeout_reset;
|
||||
}
|
||||
#endif
|
||||
@@ -9,4 +9,9 @@ int load_settings();
|
||||
bool is_folder_included(const char* path);
|
||||
bool is_folder_excluded(const char* path);
|
||||
void print_inclusions();
|
||||
|
||||
int log_timeout_get();
|
||||
void log_timeout_set(int timeout);
|
||||
void log_timeout_reset_set(int timeout);
|
||||
int log_timeout_reset_get();
|
||||
#endif
|
||||
Binary file not shown.
@@ -45,7 +45,7 @@ if($perms[2]!=="1"){
|
||||
if(isset($_GET["delete"])){
|
||||
if($perms[3]!=="1"){
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
You are not allowed to delete log entrys. (insufficient permissions)
|
||||
You are not allowed to delete log entries. (insufficient permissions)
|
||||
</div>';
|
||||
}else{
|
||||
$id=htmlspecialchars($_GET["delete"]);
|
||||
@@ -66,122 +66,63 @@ if($perms[2]!=="1"){
|
||||
}
|
||||
}
|
||||
|
||||
//get count of log entrys
|
||||
// Create a connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
|
||||
// Define page size and current page
|
||||
$page_size = 100;
|
||||
$current_page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$offset = ($current_page - 1) * $page_size;
|
||||
|
||||
// Check the connection
|
||||
// Get total number of log entries
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$sql = "SELECT count(*) AS log_count FROM log";
|
||||
$stmt = $conn->prepare($sql);
|
||||
// Execute the statement
|
||||
$stmt->execute();
|
||||
// Get the result
|
||||
$result = $stmt->get_result();
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
$num_of_log_entrys=$row["log_count"];
|
||||
$stmt->close();
|
||||
$total_entries = $row["log_count"];
|
||||
|
||||
// Calculate total pages
|
||||
$total_pages = ceil($total_entries / $page_size);
|
||||
|
||||
// Query log entries for the current page
|
||||
$sql = "SELECT * FROM log ORDER BY id DESC LIMIT ?, ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ii", $offset, $page_size);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Display log entries
|
||||
echo '<table class="table" style="overflow-x:auto">';
|
||||
echo '<thead>';
|
||||
echo '<tr>';
|
||||
echo '<th>Entry id</th><th>Loglevel</th><th>Logtext</th><th>Machine id</th><th>Time & date</th><th>Delete entry</th>';
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row["id"] . '</td>';
|
||||
echo '<td>' . $row["loglevel"] . '</td>';
|
||||
echo '<td>' . $row["logtext"] . '</td>';
|
||||
echo '<td>' . $row["machine_id"] . '</td>';
|
||||
echo '<td>' . $row["time"] . '</td>';
|
||||
echo '<td><a href="view_log.php?delete=' . $row["id"] . '">delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
$conn->close();
|
||||
|
||||
//list out log => id, loglevel, logtext, machine_id
|
||||
// Create a connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
|
||||
|
||||
// Check the connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
// Display pagination links
|
||||
echo '<nav aria-label="Page navigation">';
|
||||
echo '<ul class="pagination justify-content-center">';
|
||||
for ($i = 1; $i <= $total_pages; $i++) {
|
||||
echo '<li class="page-item ' . ($i == $current_page ? 'active' : '') . '"><a class="page-link" href="view_log.php?page=' . $i . '">' . $i . '</a></li>';
|
||||
}
|
||||
$last_id=-1;
|
||||
//create the table header
|
||||
echo('<table class="table" style="overflow-x:auto">');
|
||||
echo('<thead>');
|
||||
echo('<tr>');
|
||||
echo('<th>Entry id</th><th>Loglevel</th><th>Logtext</th><th>Machine id</th><th>Time & date</th><th>Delete entry</th>');
|
||||
echo('</tr>');
|
||||
echo('</thead>');
|
||||
echo('<tbody>');
|
||||
|
||||
//put filter options here
|
||||
if(isset($_GET["loglevel"]))
|
||||
$loglevel_ss=$_GET["loglevel"]; //put the loglevel search string to that and afterwards show it in the filter optionss. so a user sees what he has filtered for
|
||||
else
|
||||
$loglevel_ss="Loglevel";
|
||||
|
||||
if(isset($_GET["logtext"]))
|
||||
$logtext_ss=$_GET["logtext"];
|
||||
else
|
||||
$logtext_ss="Logtext";
|
||||
|
||||
if(isset($_GET["machine_id"]))
|
||||
$machine_id_ss=$_GET["machine_id"];
|
||||
else
|
||||
$machine_id_ss="Machine id";
|
||||
|
||||
if(isset($_GET["time"]))
|
||||
$time_ss=$_GET["time"];
|
||||
else
|
||||
$time_ss="Date & time";
|
||||
echo('<tr>');
|
||||
echo('<form action="view_log.php" method="get">');
|
||||
echo('<td><button type="submit" class="btn btn-primary btn-block">Filter</button></td>');
|
||||
echo('<td><input type="text" class="form-control" name="loglevel" placeholder="'.$loglevel_ss.'"></td>');
|
||||
echo('<td><input type="text" class="form-control" name="logtext" placeholder="'.$logtext_ss.'"></td>');
|
||||
echo('<td><input type="text" class="form-control" name="machine_id" placeholder="'.$machine_id_ss.'"></td>');
|
||||
echo('<td><input type="text" class="form-control" name="time" placeholder="'.$time_ss.'"></td>');
|
||||
echo('<td>---</td>');
|
||||
echo('</form>');
|
||||
echo('</tr>');
|
||||
|
||||
while($num_of_log_entrys!=0){
|
||||
$sql = "SELECT * FROM log where id > $last_id";
|
||||
$stmt = $conn->prepare($sql);
|
||||
// Execute the statement
|
||||
$stmt->execute();
|
||||
// Get the result
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$last_id=$row["id"];
|
||||
$loglevel=$row["loglevel"];
|
||||
$logtext=$row["logtext"];
|
||||
$machine_id=$row["machine_id"];
|
||||
$time=$row["time"];
|
||||
$show=true;
|
||||
//evaluate filter, decide if entry should be shown or not
|
||||
if(isset($_GET["loglevel"]) && $_GET["loglevel"]!==""){
|
||||
if(stripos($loglevel,$_GET["loglevel"])===false){
|
||||
$show=false;
|
||||
}
|
||||
}if(isset($_GET["logtext"]) && $_GET["logtext"]!==""){
|
||||
if(stripos($logtext,$_GET["logtext"])===false){
|
||||
$show=false;
|
||||
}
|
||||
}if(isset($_GET["machine_id"]) && $_GET["machine_id"]!==""){
|
||||
if(stripos($machine_id,$_GET["machine_id"])===false){
|
||||
$show=false;
|
||||
}
|
||||
}if(isset($_GET["time"]) && $_GET["time"]!==""){
|
||||
if(stripos($time,$_GET["time"])===false){
|
||||
$show=false;
|
||||
}
|
||||
}
|
||||
if($show==true){
|
||||
echo('<tr>');
|
||||
echo('<td>'.$last_id.'</td>');
|
||||
echo('<td>'.$loglevel.'</td>');
|
||||
echo('<td>'.$logtext.'</td>');
|
||||
echo('<td>'.$machine_id.'</td>');
|
||||
echo('<td>'.$time.'</td>');
|
||||
echo('<td><a href="view_log.php?delete='.$last_id.'">delete</a></td>');
|
||||
echo('</tr>');
|
||||
}
|
||||
$stmt->close();
|
||||
$num_of_log_entrys--;
|
||||
}
|
||||
echo('</tbody>');
|
||||
echo('</table>');
|
||||
$conn->close();
|
||||
echo '</ul>';
|
||||
echo '</nav>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user