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;
|
||||
static Socket::Server * serv_sock_pointer = 0;
|
||||
unsigned int Util::Config::printDebugLevel = DEBUG;//
|
||||
std::string Util::Config::streamName;
|
||||
|
||||
Util::Config::Config() {
|
||||
//global options here
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Util {
|
|||
//variables
|
||||
static bool is_active; ///< Set to true by activate(), set to false by the signal handler.
|
||||
static unsigned int printDebugLevel;
|
||||
static std::string streamName; ///< Used by debug messages to identify the stream name
|
||||
//functions
|
||||
Config();
|
||||
Config(std::string cmd);
|
||||
|
|
|
@ -34,15 +34,15 @@ static const char * DBG_LVL_LIST[] = {"NONE", "FAIL", "ERROR", "WARN", "INFO", "
|
|||
#include <errno.h>
|
||||
|
||||
#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
|
||||
#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
|
||||
#else
|
||||
#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
|
||||
#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
|
||||
|
||||
|
|
27
lib/util.cpp
27
lib/util.cpp
|
@ -250,10 +250,12 @@ namespace Util{
|
|||
void logParser(int in, int out, bool colored, void callback(std::string, std::string, bool)){
|
||||
char buf[1024];
|
||||
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){
|
||||
color_end = (char*)"\033[0m";
|
||||
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";
|
||||
if (getenv("MIST_COLOR_TIME")){color_time = getenv("MIST_COLOR_TIME");}
|
||||
CONF_msg = (char*)"\033[0;1;37m";
|
||||
|
@ -268,6 +270,7 @@ namespace Util{
|
|||
if (getenv("MIST_COLOR_INFO")){INFO_msg = getenv("MIST_COLOR_INFO");}
|
||||
}else{
|
||||
color_end = (char*)"";
|
||||
color_strm = (char*)"";
|
||||
color_time = (char*)"";
|
||||
CONF_msg = (char*)"";
|
||||
FAIL_msg = (char*)"";
|
||||
|
@ -281,6 +284,7 @@ namespace Util{
|
|||
char * progname = 0;
|
||||
char * progpid = 0;
|
||||
char * lineno = 0;
|
||||
char * strmNm = 0;
|
||||
char * message = 0;
|
||||
while (i < 9 && buf[i] != '|' && buf[i] != 0){++i;}
|
||||
if (buf[i] == '|'){
|
||||
|
@ -301,11 +305,22 @@ namespace Util{
|
|||
lineno = buf+i;//lineno starts here
|
||||
}
|
||||
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] == '|'){
|
||||
buf[i] = 0;//insert null byte
|
||||
++i;
|
||||
message = buf+i;//message starts here
|
||||
}
|
||||
if (!message){
|
||||
message = strmNm;
|
||||
strmNm = 0;
|
||||
if (message){i = message-buf;}
|
||||
}
|
||||
//find end of line, insert null byte
|
||||
unsigned int j = i;
|
||||
while (j < 1023 && buf[j] != '\n' && buf[j] != 0){++j;}
|
||||
|
@ -330,7 +345,15 @@ namespace Util{
|
|||
strftime(buffer, 100, "%F %H:%M:%S", timeinfo);
|
||||
dprintf(out, "%s[%s] ", color_time, buffer);
|
||||
if (progname && progpid && strlen(progname) && strlen(progpid)){
|
||||
dprintf(out, "%s (%s) ", progname, 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);
|
||||
}
|
||||
}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);
|
||||
if (lineno && strlen(lineno)){
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Controller{
|
|||
rlxLogs->setEndPos(logCounter);
|
||||
}
|
||||
}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[]){
|
||||
if (!(config->parseArgs(argc, argv))){return 1;}
|
||||
streamName = nProxy.streamName = config->getString("streamname");
|
||||
Util::Config::streamName = streamName;
|
||||
|
||||
if (config->getBool("json")) {
|
||||
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 (!streamName.size() && config->hasOption("streamname")){
|
||||
streamName = config->getString("streamname");
|
||||
Util::Config::streamName = streamName;
|
||||
}
|
||||
|
||||
/*LTS-START*/
|
||||
|
|
Loading…
Add table
Reference in a new issue