|
|
@ -13,7 +13,8 @@ Log::Log() |
|
|
|
this->delimiter = ""; |
|
|
|
this->lineNumber = 0; |
|
|
|
this->objectName = NULL; |
|
|
|
|
|
|
|
this->currentLine = 0; |
|
|
|
this->firstLine = 0; |
|
|
|
this->writeMutex = Log::getMutex(); |
|
|
|
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; |
|
|
|
#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) |
|
|
|
{ |
|
|
|
this->objectName = objectName; |
|
|
|
} |
|
|
|
|
|
|
|
void Log::print(string msg, bool force) |
|
|
|
void Log::print(string msg, bool force, int customLine) |
|
|
|
{ |
|
|
|
#ifndef DEBUG
|
|
|
|
if (this->getObjectName() == NULL) |
|
|
@ -136,7 +168,10 @@ void Log::print(string msg, bool force) |
|
|
|
return; |
|
|
|
|
|
|
|
pthread_mutex_lock(this->writeMutex); |
|
|
|
move(this->getLineNumber(), 0); |
|
|
|
if (customLine > -1) |
|
|
|
move(customLine, 0); |
|
|
|
else |
|
|
|
move(this->getLineNumber(), 0); |
|
|
|
clrtoeol(); |
|
|
|
|
|
|
|
if(has_colors()) |
|
|
|