Skip to content

Commit

Permalink
Added more loggings
Browse files Browse the repository at this point in the history
  • Loading branch information
rahsing committed Oct 27, 2020
1 parent dc4ed47 commit 1dbc58a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
12 changes: 9 additions & 3 deletions Unix/agent/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void ResetLog()
conf = Conf_Open(path);
if (!conf)
{
err(ZT("failed to open configuration file: %s"), scs(path));
trace_CriticalError("Failed to open configuration file");
return;
}

/* For each key=value pair in configuration file */
Expand All @@ -112,15 +113,20 @@ void ResetLog()

if (r == -1)
{
err(ZT("%s: %s\n"), path, scs(Conf_Error(conf)));
trace_CriticalError("Incorrect entry in configuration file");
break;
}

if (r == 1)
break;

if (strcmp(key, "loglevel") == 0)
{
Log_SetLevelFromString(value);
if (Log_SetLevelFromString(value) != 0)
{
trace_CriticalError("Incorrect loglevel set in configuration file");
}
break;
}
}

Expand Down
14 changes: 7 additions & 7 deletions Unix/configeditor/configeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ OPTIONS:\n\
-h, --help Print this help message.\n\
-v, --version Print version information.\n\
--debug Enable debug output.\n\
--reconfigure Apply omiserver.conf file changes dynamically\n\
--reconfig Apply omiserver.conf file changes dynamically\n\
Currently we are only supporting loglevel\n\
\n\
Actions:\n\
Expand Down Expand Up @@ -134,7 +134,7 @@ static void GetCommandLineOptions(
"--uncomment",
"-q:",
"--query:",
"--reconfigure",
"--reconfig",
NULL
};

Expand Down Expand Up @@ -218,7 +218,7 @@ static void GetCommandLineOptions(
if (options.query.find(",") != string::npos)
err(ZT("Not allowed to query element with embedded comma: %s"), scs(state.arg));
}
else if (strcmp(state.opt, "--reconfigure") == 0)
else if (strcmp(state.opt, "--reconfig") == 0)
{
options.reconfig = true;
}
Expand Down Expand Up @@ -345,10 +345,10 @@ int MI_MAIN_CALL main(int argc, const char** argv)
#else
result = system("ps -A -o pid,comm | awk '$2~/omiagent/{print $1}' | xargs kill -s SIGUSR2");
#endif
if(result == 0)
if(result != 0)
{
Ftprintf(stderr, ZT("Settings has been applied Dynamically\n"));
}
cout << "Settings has not been applied Dynamically\n" << std::endl;
}
}
else
{
Expand All @@ -357,7 +357,7 @@ int MI_MAIN_CALL main(int argc, const char** argv)
}
else
{
err(ZT("Server is not running\n"));
err(ZT("OMI Server is not running\n"));
}
exit(1);
}
Expand Down
21 changes: 17 additions & 4 deletions Unix/server/servercommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,37 +435,50 @@ void OpenLogFile()
}

void ResetLog()
{
{
char path[PAL_MAX_PATH_SIZE];
Conf* conf;

/* Form the configuration file path */
Strlcpy(path, OMI_GetPath(ID_CONFIGFILE), sizeof(path));

/* Open the configuration file */
conf = Conf_Open(path);
if (!conf)
{
err(ZT("failed to open configuration file: %s"), scs(path));
trace_CriticalError("Failed to open configuration file");
return;
}

/* For each key=value pair in configuration file */
for (;;)
{
const char* key;
const char* value;
int r = Conf_Read(conf, &key, &value);

if (r == -1)
{
err(ZT("%s: %s\n"), path, scs(Conf_Error(conf)));
trace_CriticalError("Incorrect entry in configuration file");
break;
}

if (r == 1)
break;

if (strcmp(key, "loglevel") == 0)
{
Log_SetLevelFromString(value);
if (Log_SetLevelFromString(value) != 0)
{
trace_CriticalError("Incorrect loglevel set in configuration file");
}
break;
}
}

/* Close configuration file */
Conf_Close(conf);

return;
}

Expand Down

0 comments on commit 1dbc58a

Please sign in to comment.