Skip to content

Commit

Permalink
change logging default, add os info to json
Browse files Browse the repository at this point in the history
  • Loading branch information
brubsby committed Jul 23, 2024
1 parent a23f5e5 commit dc95ed8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
6 changes: 3 additions & 3 deletions mfaktc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ PrintMode=0
# 0: do not append stdout lines to mfaktc.log
# 1: append stdout lines to mfaktc.log
#
# Default: Logging=1
# Default: Logging=0

Logging=1
Logging=0


# allow the CPU to sleep if nothing can be preprocessed?
Expand All @@ -180,7 +180,7 @@ AllowSleep=0
#ComputerID=Ananke


# TimeStampInResults allows to configure if each output line in the results
# TimeStampInResults allows to configure if each output line in the results.txt
# file should be preceeded with a date-and-time stamp (similar to prime95)
#
# Default: TimeStampInResults=0
Expand Down
4 changes: 0 additions & 4 deletions src/mfaktc.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,6 @@ int main(int argc, char **argv)
sleeptest();
return 0;
}
else if (!strcmp((char*)"-nolog", argv[i]))
{
mystuff.logging = 0;
}
else if(!strcmp((char*)"-v", argv[i]))
{
if(i+1 >= argc)
Expand Down
2 changes: 1 addition & 1 deletion src/my_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef struct

int quit;
int verbosity; /* 0 = reduced number of screen printfs, 1 = default, >= 2 = some additional printfs */
int logging; /* 0 = logging disabled, 1 = logging enabled (default) */
int logging; /* 0 = logging disabled (default), 1 = logging enabled */

int selftestsize;
int selftestrandomoffset;
Expand Down
33 changes: 30 additions & 3 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ void print_status_line(mystuff_t *mystuff)
logf(mystuff, "%s", buffer);
}

const char* getArchitectureJSON() {
#if defined(__x86_64__) || defined(_M_X64)
return ", \"architecture\": \"x86_64\"";
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
return ", \"architecture\": \"x86_32\"";
#elif defined(__aarch64__) || defined(_M_ARM64)
return ", \"architecture\": \"ARM64\"";
#else
return "";
#endif
}

void getOSJSON(char* string) {
#if defined(_WIN32) || defined(_WIN64)
sprintf(string, ", \"os\":{\"os\": \"Windows\"%s}", getArchitectureJSON());
#elif defined(__linux__)
sprintf(string ", \"os\":{\"os\": \"Linux\"%s}", getArchitectureJSON());
#endif
}


void print_result_line(mystuff_t *mystuff, int factorsfound)
/* printf the final result line (STDOUT and resultfile) */
Expand All @@ -379,12 +399,13 @@ void print_result_line(mystuff_t *mystuff, int factorsfound)
char userjson[61]; /* 50 (V5UserID) + 11 spare */
char computerjson[65]; /* 50 (ComputerID) + 15 spare */
char factorjson[513];
char osjson[200];
char txtstring[200];

FILE *txtresultfile=NULL;

#ifndef WAGSTAFF
char jsonstring[1000];
char jsonstring[1100];
FILE *jsonresultfile=NULL;
#endif

Expand All @@ -393,22 +414,28 @@ void print_result_line(mystuff_t *mystuff, int factorsfound)
sprintf(UID, "UID: %s/%s, ", mystuff->V5UserID, mystuff->ComputerID);
else
UID[0]=0;

if (mystuff->assignment_key[0])
sprintf(aidjson, ", \"aid\":\"%s\"", mystuff->assignment_key);
else
aidjson[0] = 0;

if (mystuff->V5UserID[0])
sprintf(userjson, ", \"user\":\"%s\"", mystuff->V5UserID);
else
userjson[0] = 0;

if (mystuff->ComputerID[0])
sprintf(computerjson, ", \"computer\":\"%s\"", mystuff->ComputerID);
else
computerjson[0] = 0;

if (mystuff->factorsstring[0])
sprintf(factorjson, ", \"factors\":[%s]", mystuff->factorsstring);
else
factorjson[0] = 0;

getOSJSON(osjson);

if(mystuff->mode == MODE_NORMAL)
{
Expand All @@ -433,8 +460,8 @@ void print_result_line(mystuff_t *mystuff, int factorsfound)
sprintf(txtstring, "no factor for %s%u from 2^%d to 2^%d [mfaktc %s %s]", NAME_NUMBERS, mystuff->exponent, mystuff->bit_min, mystuff->bit_max_stage, MFAKTC_VERSION, mystuff->stats.kernelname);
}
#ifndef WAGSTAFF
sprintf(jsonstring, "{\"exponent\":%u, \"worktype\":\"TF\", \"status\":\"%s\", \"bitlo\":%2d, \"bithi\":%2d, \"rangecomplete\":%s%s, \"program\":{\"name\":\"mfaktc\", \"version\":\"%s\", \"subversion\":\"%s\"}, \"timestamp\":\"%s\"%s%s%s}",
mystuff->exponent, factorsfound > 0 ? "F" : "NF", mystuff->bit_min, mystuff->bit_max_stage, partialresult ? "false" : "true", factorjson, MFAKTC_VERSION, mystuff->stats.kernelname, get_utc_timestamp(), userjson, computerjson, aidjson);
sprintf(jsonstring, "{\"exponent\":%u, \"worktype\":\"TF\", \"status\":\"%s\", \"bitlo\":%2d, \"bithi\":%2d, \"rangecomplete\":%s%s, \"program\":{\"name\":\"mfaktc\", \"version\":\"%s\", \"subversion\":\"%s\"}, \"timestamp\":\"%s\"%s%s%s%s}",
mystuff->exponent, factorsfound > 0 ? "F" : "NF", mystuff->bit_min, mystuff->bit_max_stage, partialresult ? "false" : "true", factorjson, MFAKTC_VERSION, mystuff->stats.kernelname, get_utc_timestamp(), userjson, computerjson, aidjson, osjson);
#endif
if(mystuff->mode != MODE_SELFTEST_SHORT)
{
Expand Down
8 changes: 4 additions & 4 deletions src/read_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ int read_config(mystuff_t *mystuff)
{
if (my_read_int("mfaktc.ini", "Logging", &i))
{
logf(mystuff, "WARNING: Cannot read Logging from mfaktc.ini, set to 1 by default\n");
i = 1;
logf(mystuff, "WARNING: Cannot read Logging from mfaktc.ini, set to 0 by default\n");
i = 0;
}
else if (i != 0 && i != 1)
{
logf(mystuff, "WARNING: Logging must be 0 or 1, set to 1 by default\n");
i = 1;
logf(mystuff, "WARNING: Logging must be 0 or 1, set to 0 by default\n");
i = 0;
}
if (mystuff->verbosity >= 1)
{
Expand Down

0 comments on commit dc95ed8

Please sign in to comment.