Merge branch 'development' into LTS_development
This commit is contained in:
commit
83665c4e3b
7 changed files with 34 additions and 7 deletions
|
@ -37,6 +37,7 @@
|
||||||
bool Util::Config::is_active = false;
|
bool Util::Config::is_active = false;
|
||||||
static Socket::Server * serv_sock_pointer = 0;
|
static Socket::Server * serv_sock_pointer = 0;
|
||||||
unsigned int Util::Config::printDebugLevel = DEBUG;//
|
unsigned int Util::Config::printDebugLevel = DEBUG;//
|
||||||
|
std::string Util::Config::streamName;
|
||||||
|
|
||||||
Util::Config::Config() {
|
Util::Config::Config() {
|
||||||
//global options here
|
//global options here
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Util {
|
||||||
//variables
|
//variables
|
||||||
static bool is_active; ///< Set to true by activate(), set to false by the signal handler.
|
static bool is_active; ///< Set to true by activate(), set to false by the signal handler.
|
||||||
static unsigned int printDebugLevel;
|
static unsigned int printDebugLevel;
|
||||||
|
static std::string streamName; ///< Used by debug messages to identify the stream name
|
||||||
//functions
|
//functions
|
||||||
Config();
|
Config();
|
||||||
Config(std::string cmd);
|
Config(std::string cmd);
|
||||||
|
|
|
@ -34,15 +34,15 @@ static const char * DBG_LVL_LIST[] = {"NONE", "FAIL", "ERROR", "WARN", "INFO", "
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#if DEBUG >= DLVL_DEVEL
|
#if DEBUG >= DLVL_DEVEL
|
||||||
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|%s|%d|%s:%d|" msg "\n", DBG_LVL_LIST[lvl], program_invocation_short_name, getpid(), __FILE__, __LINE__, ##__VA_ARGS__);}
|
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|%s|%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], program_invocation_short_name, getpid(), __FILE__, __LINE__, Util::Config::streamName.c_str(), ##__VA_ARGS__);}
|
||||||
#else
|
#else
|
||||||
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|%s|%d||" msg "\n", DBG_LVL_LIST[lvl], program_invocation_short_name, getpid(), ##__VA_ARGS__);}
|
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s|%s|%d||%s|" msg "\n", DBG_LVL_LIST[lvl], program_invocation_short_name, getpid(), Util::Config::streamName.c_str(), ##__VA_ARGS__);}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if DEBUG >= DLVL_DEVEL
|
#if DEBUG >= DLVL_DEVEL
|
||||||
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d|%s:%d|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, __LINE__, ##__VA_ARGS__);}
|
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d|%s:%d|%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), __FILE__, __LINE__, Util::Config::streamName.c_str(), ##__VA_ARGS__);}
|
||||||
#else
|
#else
|
||||||
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d||" msg "\n", DBG_LVL_LIST[lvl], getpid(), ##__VA_ARGS__);}
|
#define DEBUG_MSG(lvl, msg, ...) if (Util::Config::printDebugLevel >= lvl){fprintf(stderr, "%s||%d||%s|" msg "\n", DBG_LVL_LIST[lvl], getpid(), Util::Config::streamName.c_str(), ##__VA_ARGS__);}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
25
lib/util.cpp
25
lib/util.cpp
|
@ -250,10 +250,12 @@ namespace Util{
|
||||||
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(std::string, 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, *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;
|
||||||
if (colored){
|
if (colored){
|
||||||
color_end = (char*)"\033[0m";
|
color_end = (char*)"\033[0m";
|
||||||
if (getenv("MIST_COLOR_END")){color_end = getenv("MIST_COLOR_END");}
|
if (getenv("MIST_COLOR_END")){color_end = getenv("MIST_COLOR_END");}
|
||||||
|
color_strm = (char*)"\033[0m";
|
||||||
|
if (getenv("MIST_COLOR_STREAM")){color_strm = getenv("MIST_COLOR_STREAM");}
|
||||||
color_time = (char*)"\033[2m";
|
color_time = (char*)"\033[2m";
|
||||||
if (getenv("MIST_COLOR_TIME")){color_time = getenv("MIST_COLOR_TIME");}
|
if (getenv("MIST_COLOR_TIME")){color_time = getenv("MIST_COLOR_TIME");}
|
||||||
CONF_msg = (char*)"\033[0;1;37m";
|
CONF_msg = (char*)"\033[0;1;37m";
|
||||||
|
@ -268,6 +270,7 @@ namespace Util{
|
||||||
if (getenv("MIST_COLOR_INFO")){INFO_msg = getenv("MIST_COLOR_INFO");}
|
if (getenv("MIST_COLOR_INFO")){INFO_msg = getenv("MIST_COLOR_INFO");}
|
||||||
}else{
|
}else{
|
||||||
color_end = (char*)"";
|
color_end = (char*)"";
|
||||||
|
color_strm = (char*)"";
|
||||||
color_time = (char*)"";
|
color_time = (char*)"";
|
||||||
CONF_msg = (char*)"";
|
CONF_msg = (char*)"";
|
||||||
FAIL_msg = (char*)"";
|
FAIL_msg = (char*)"";
|
||||||
|
@ -281,6 +284,7 @@ namespace Util{
|
||||||
char * progname = 0;
|
char * progname = 0;
|
||||||
char * progpid = 0;
|
char * progpid = 0;
|
||||||
char * lineno = 0;
|
char * lineno = 0;
|
||||||
|
char * strmNm = 0;
|
||||||
char * message = 0;
|
char * message = 0;
|
||||||
while (i < 9 && buf[i] != '|' && buf[i] != 0){++i;}
|
while (i < 9 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||||
if (buf[i] == '|'){
|
if (buf[i] == '|'){
|
||||||
|
@ -301,11 +305,22 @@ namespace Util{
|
||||||
lineno = buf+i;//lineno starts here
|
lineno = buf+i;//lineno starts here
|
||||||
}
|
}
|
||||||
while (i < 180 && buf[i] != '|' && buf[i] != 0){++i;}
|
while (i < 180 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||||
|
if (buf[i] == '|'){
|
||||||
|
buf[i] = 0;//insert null byte
|
||||||
|
++i;
|
||||||
|
strmNm = buf+i;//stream name starts here
|
||||||
|
}
|
||||||
|
while (i < 380 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||||
if (buf[i] == '|'){
|
if (buf[i] == '|'){
|
||||||
buf[i] = 0;//insert null byte
|
buf[i] = 0;//insert null byte
|
||||||
++i;
|
++i;
|
||||||
message = buf+i;//message starts here
|
message = buf+i;//message starts here
|
||||||
}
|
}
|
||||||
|
if (!message){
|
||||||
|
message = strmNm;
|
||||||
|
strmNm = 0;
|
||||||
|
if (message){i = message-buf;}
|
||||||
|
}
|
||||||
//find end of line, insert null byte
|
//find end of line, insert null byte
|
||||||
unsigned int j = i;
|
unsigned int j = i;
|
||||||
while (j < 1023 && buf[j] != '\n' && buf[j] != 0){++j;}
|
while (j < 1023 && buf[j] != '\n' && buf[j] != 0){++j;}
|
||||||
|
@ -330,8 +345,16 @@ namespace Util{
|
||||||
strftime(buffer, 100, "%F %H:%M:%S", timeinfo);
|
strftime(buffer, 100, "%F %H:%M:%S", timeinfo);
|
||||||
dprintf(out, "%s[%s] ", color_time, buffer);
|
dprintf(out, "%s[%s] ", color_time, buffer);
|
||||||
if (progname && progpid && strlen(progname) && strlen(progpid)){
|
if (progname && progpid && strlen(progname) && strlen(progpid)){
|
||||||
|
if (strmNm && strlen(strmNm)){
|
||||||
|
dprintf(out, "%s:%s%s%s (%s) ", progname, color_strm, strmNm, color_time, progpid);
|
||||||
|
}else{
|
||||||
dprintf(out, "%s (%s) ", progname, progpid);
|
dprintf(out, "%s (%s) ", progname, progpid);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
if (strmNm && strlen(strmNm)){
|
||||||
|
dprintf(out, "%s%s%s ", color_strm, strmNm, color_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
dprintf(out, "%s%s: %s%s", color_msg, kind, message, color_end);
|
dprintf(out, "%s%s: %s%s", color_msg, kind, message, color_end);
|
||||||
if (lineno && strlen(lineno)){
|
if (lineno && strlen(lineno)){
|
||||||
dprintf(out, " (%s) ", lineno);
|
dprintf(out, " (%s) ", lineno);
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Controller{
|
||||||
rlxLogs->setEndPos(logCounter);
|
rlxLogs->setEndPos(logCounter);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
std::cerr << kind << "|MistController|" << getpid() << "||" << message << "\n";
|
std::cerr << kind << "|MistController|" << getpid() << "|||" << message << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,7 @@ namespace Mist {
|
||||||
int Input::boot(int argc, char * argv[]){
|
int Input::boot(int argc, char * argv[]){
|
||||||
if (!(config->parseArgs(argc, argv))){return 1;}
|
if (!(config->parseArgs(argc, argv))){return 1;}
|
||||||
streamName = nProxy.streamName = config->getString("streamname");
|
streamName = nProxy.streamName = config->getString("streamname");
|
||||||
|
Util::Config::streamName = streamName;
|
||||||
|
|
||||||
if (config->getBool("json")) {
|
if (config->getBool("json")) {
|
||||||
std::cout << capa.toString() << std::endl;
|
std::cout << capa.toString() << std::endl;
|
||||||
|
|
|
@ -92,6 +92,7 @@ namespace Mist{
|
||||||
//If we have a streamname option, set internal streamname to that option
|
//If we have a streamname option, set internal streamname to that option
|
||||||
if (!streamName.size() && config->hasOption("streamname")){
|
if (!streamName.size() && config->hasOption("streamname")){
|
||||||
streamName = config->getString("streamname");
|
streamName = config->getString("streamname");
|
||||||
|
Util::Config::streamName = streamName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*LTS-START*/
|
/*LTS-START*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue