Merge branch 'development' into LTS_development
This commit is contained in:
commit
e3e5b39a62
4 changed files with 9 additions and 5 deletions
|
@ -247,7 +247,8 @@ namespace Util{
|
||||||
|
|
||||||
/// Parses log messages from the given file descriptor in, printing them to out, optionally calling the given callback for each valid message.
|
/// Parses log messages from the given file descriptor in, printing them to out, optionally calling the given callback for each valid message.
|
||||||
/// Closes the file descriptor on read error
|
/// Closes the file descriptor on read error
|
||||||
void logParser(int in, int out, bool colored, void callback(std::string, std::string, bool)){
|
void logParser(int in, int out, bool colored, void callback(const std::string &, const std::string &, const std::string &, bool)){
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
FILE *output = fdopen(in, "r");
|
FILE *output = fdopen(in, "r");
|
||||||
char *color_time, *color_msg, *color_end, *color_strm, *CONF_msg, *FAIL_msg, *ERROR_msg, *WARN_msg, *INFO_msg;
|
char *color_time, *color_msg, *color_end, *color_strm, *CONF_msg, *FAIL_msg, *ERROR_msg, *WARN_msg, *INFO_msg;
|
||||||
|
@ -327,7 +328,7 @@ namespace Util{
|
||||||
buf[j] = 0;
|
buf[j] = 0;
|
||||||
//print message
|
//print message
|
||||||
if (message){
|
if (message){
|
||||||
if (callback){callback(kind, message, true);}
|
if (callback){callback(kind, message, strmNm, true);}
|
||||||
color_msg = color_end;
|
color_msg = color_end;
|
||||||
if (colored){
|
if (colored){
|
||||||
if (!strcmp(kind, "CONF")){color_msg = CONF_msg;}
|
if (!strcmp(kind, "CONF")){color_msg = CONF_msg;}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Util{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void logParser(int in, int out, bool colored, void callback(std::string, std::string, bool) = 0);
|
void logParser(int in, int out, bool colored, void callback(const std::string &, const std::string &, const std::string &, bool) = 0);
|
||||||
void redirectLogsIfNeeded();
|
void redirectLogsIfNeeded();
|
||||||
|
|
||||||
/// Holds type, size and offset for RelAccX class internal data fields.
|
/// Holds type, size and offset for RelAccX class internal data fields.
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Controller{
|
||||||
///\brief Store and print a log message.
|
///\brief Store and print a log message.
|
||||||
///\param kind The type of message.
|
///\param kind The type of message.
|
||||||
///\param message The message to be logged.
|
///\param message The message to be logged.
|
||||||
void Log(std::string kind, std::string message, bool noWriteToLog){
|
void Log(const std::string & kind, const std::string & message, const std::string & stream, bool noWriteToLog){
|
||||||
if (noWriteToLog){
|
if (noWriteToLog){
|
||||||
tthread::lock_guard<tthread::mutex> guard(logMutex);
|
tthread::lock_guard<tthread::mutex> guard(logMutex);
|
||||||
JSON::Value m;
|
JSON::Value m;
|
||||||
|
@ -57,6 +57,7 @@ namespace Controller{
|
||||||
m.append(logTime);
|
m.append(logTime);
|
||||||
m.append(kind);
|
m.append(kind);
|
||||||
m.append(message);
|
m.append(message);
|
||||||
|
m.append(stream);
|
||||||
Storage["log"].append(m);
|
Storage["log"].append(m);
|
||||||
Storage["log"].shrink(100); // limit to 100 log messages
|
Storage["log"].shrink(100); // limit to 100 log messages
|
||||||
logCounter++;
|
logCounter++;
|
||||||
|
@ -69,6 +70,7 @@ namespace Controller{
|
||||||
rlxLogs->setInt("time", logTime, logCounter-1);
|
rlxLogs->setInt("time", logTime, logCounter-1);
|
||||||
rlxLogs->setString("kind", kind, logCounter-1);
|
rlxLogs->setString("kind", kind, logCounter-1);
|
||||||
rlxLogs->setString("msg", message, logCounter-1);
|
rlxLogs->setString("msg", message, logCounter-1);
|
||||||
|
rlxLogs->setString("strm", stream, logCounter-1);
|
||||||
rlxLogs->setEndPos(logCounter);
|
rlxLogs->setEndPos(logCounter);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -125,6 +127,7 @@ namespace Controller{
|
||||||
rlxLogs->addField("time", RAX_64UINT);
|
rlxLogs->addField("time", RAX_64UINT);
|
||||||
rlxLogs->addField("kind", RAX_32STRING);
|
rlxLogs->addField("kind", RAX_32STRING);
|
||||||
rlxLogs->addField("msg", RAX_512STRING);
|
rlxLogs->addField("msg", RAX_512STRING);
|
||||||
|
rlxLogs->addField("strm", RAX_128STRING);
|
||||||
rlxLogs->setReady();
|
rlxLogs->setReady();
|
||||||
}
|
}
|
||||||
maxLogsRecs = (1024*1024 - rlxLogs->getOffset()) / rlxLogs->getRSize();
|
maxLogsRecs = (1024*1024 - rlxLogs->getOffset()) / rlxLogs->getRSize();
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Controller {
|
||||||
Util::RelAccX * streamsAccessor();
|
Util::RelAccX * streamsAccessor();
|
||||||
|
|
||||||
/// Store and print a log message.
|
/// Store and print a log message.
|
||||||
void Log(std::string kind, std::string message, bool noWriteToLog = false);
|
void Log(const std::string & kind, const std::string & message, const std::string & stream = "", bool noWriteToLog = false);
|
||||||
void logAccess(const std::string & sessId, const std::string & strm, const std::string & conn, const std::string & host, uint64_t duration, uint64_t up, uint64_t down, const std::string & tags);
|
void logAccess(const std::string & sessId, const std::string & strm, const std::string & conn, const std::string & host, uint64_t duration, uint64_t up, uint64_t down, const std::string & tags);
|
||||||
|
|
||||||
/// Write contents to Filename.
|
/// Write contents to Filename.
|
||||||
|
|
Loading…
Add table
Reference in a new issue