|
@ -13,7 +13,8 @@ Log::Log() |
|
|
this->delimiter = ""; |
|
|
this->delimiter = ""; |
|
|
this->lineNumber = 0; |
|
|
this->lineNumber = 0; |
|
|
this->objectName = NULL; |
|
|
this->objectName = NULL; |
|
|
|
|
|
|
|
|
|
|
|
this->currentLine = 0; |
|
|
|
|
|
this->firstLine = 0; |
|
|
this->writeMutex = Log::getMutex(); |
|
|
this->writeMutex = Log::getMutex(); |
|
|
this->setDelay(1); |
|
|
this->setDelay(1); |
|
|
} |
|
|
} |
|
@ -120,13 +121,44 @@ void Log::printProgressBar(int lineNumber, int offset, string msg, |
|
|
cout << this->getObjectName()->c_str() << ": " << this->getDelimiter() << msg << endl; |
|
|
cout << this->getObjectName()->c_str() << ": " << this->getDelimiter() << msg << endl; |
|
|
#endif
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
/*
|
|
|
|
|
|
* metoda wypisuje log w wielu liniach od firstLineNumber do rows-2 |
|
|
|
|
|
*/ |
|
|
|
|
|
void Log::printLine(string msg, bool force) |
|
|
|
|
|
{ |
|
|
|
|
|
int cols, rows; |
|
|
|
|
|
getmaxyx(stdscr, rows, cols); |
|
|
|
|
|
|
|
|
|
|
|
if (this->currentLine > rows-3) |
|
|
|
|
|
this->currentLine = this->firstLine; |
|
|
|
|
|
|
|
|
|
|
|
this->print(msg, force, this->currentLine); |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(this->writeMutex); |
|
|
|
|
|
move(this->currentLine+1, 0); |
|
|
|
|
|
clrtoeol(); |
|
|
|
|
|
move(0,0); |
|
|
|
|
|
pthread_mutex_unlock(this->writeMutex); |
|
|
|
|
|
++this->currentLine; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int Log::getFirstLine() const |
|
|
|
|
|
{ |
|
|
|
|
|
return firstLine; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Log::setFirstLine(int firstLine) |
|
|
|
|
|
{ |
|
|
|
|
|
this->firstLine = firstLine; |
|
|
|
|
|
this->currentLine = firstLine; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void Log::setObjectName(string* objectName) |
|
|
void Log::setObjectName(string* objectName) |
|
|
{ |
|
|
{ |
|
|
this->objectName = objectName; |
|
|
this->objectName = objectName; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Log::print(string msg, bool force) |
|
|
|
|
|
|
|
|
void Log::print(string msg, bool force, int customLine) |
|
|
{ |
|
|
{ |
|
|
#ifndef DEBUG
|
|
|
#ifndef DEBUG
|
|
|
if (this->getObjectName() == NULL) |
|
|
if (this->getObjectName() == NULL) |
|
@ -136,7 +168,10 @@ void Log::print(string msg, bool force) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
pthread_mutex_lock(this->writeMutex); |
|
|
pthread_mutex_lock(this->writeMutex); |
|
|
move(this->getLineNumber(), 0); |
|
|
|
|
|
|
|
|
if (customLine > -1) |
|
|
|
|
|
move(customLine, 0); |
|
|
|
|
|
else |
|
|
|
|
|
move(this->getLineNumber(), 0); |
|
|
clrtoeol(); |
|
|
clrtoeol(); |
|
|
|
|
|
|
|
|
if(has_colors()) |
|
|
if(has_colors()) |
|
|