53 cout.write(fBacklog.data(), fBacklog.size());
64 const int w = getmaxx(fWindow);
73 for (
unsigned int i=0;
i<fBacklog.size();
i++)
75 if (fAttributes.find(
i)!=fAttributes.end())
76 fAttributes[
i]==-1 ? wattrset(fWindow, 0) : wattron(fWindow, fAttributes[
i]);
78 if (fBacklog[i]==
'\n')
85 wprintw(fWindow,
"%c", fBacklog[i]);
116 if (fLogFile.is_open())
119 fLogFile.open(filename, append ? ios::app|ios::out : ios::out);
125 return fLogFile.is_open();
168 const int len = fPPtr - fBase;
188 const string sout = string(fBase, len);
189 wprintw(fWindow,
"%s", sout.c_str());
193 if (fBase[len-1]==
'\n')
194 wattrset(fWindow, 0);
200 cout.write(fBase, len);
203 if (fBase[len-1]==
'\n')
214 fBacklog.insert(fBacklog.end(), fBase, fBase+len);
218 if (fBase[len-1]==
'\n')
222 const char *
reset =
"\033[0m";
223 fBacklog.insert(fBacklog.end(),
reset, reset+4);
227 fAttributes[fBacklog.size()] = -1;
229 fMuxBacklog.unlock();
232 fQueueFile.emplace(fBase, len);
280 int s = GetSizeBacklog()/1000;
308 if ((m&COLOR_PAIR(
kRed) )==COLOR_PAIR(
kRed) ) rc +=
"\033[31m";
309 if ((m&COLOR_PAIR(
kGreen) )==COLOR_PAIR(
kGreen) ) rc +=
"\033[32m";
310 if ((m&COLOR_PAIR(
kYellow) )==COLOR_PAIR(
kYellow) ) rc +=
"\033[33m";
311 if ((m&COLOR_PAIR(
kBlue) )==COLOR_PAIR(
kBlue) ) rc +=
"\033[34m";
313 if ((m&COLOR_PAIR(
kCyan) )==COLOR_PAIR(
kCyan) ) rc +=
"\033[36m";
314 if ((m&COLOR_PAIR(
kWhite) )==COLOR_PAIR(
kWhite) ) rc +=
"\033[0m\033[1m";
316 if ((m&
kBold )==kBold ) rc +=
"\033[1m";
317 if ((m&
kDim )==kDim ) rc +=
"\033[2m";
318 if ((m&
kUnderline)==kUnderline) rc +=
"\033[4m";
319 if ((m&
kBlink )==kBlink ) rc +=
"\033[5m";
334 const int col = COLOR_PAIR(m);
339 *
this << GetAnsiAttr(col);
346 wattron(fWindow, col);
350 fAttributes[fBacklog.size()] |= col;
351 fMuxBacklog.unlock();
367 *
this << GetAnsiAttr(m);
374 m==
kReset ? wattrset(fWindow, 0) : wattron(fWindow, m);
379 fAttributes[fBacklog.size()] = -1 :
380 fAttributes[fBacklog.size()] |= m;
381 fMuxBacklog.unlock();
bool WriteFile(const std::string &)
static std::string GetAnsiAttr(int m)
void CloseLogFile()
Close a log-file.
A C++ ostream to an ncurses window supporting attributes and colors.
void EmptyBacklog()
Empty backlog.
WindowLogColor
Stream manipulators to change the color of a WindowLog stream.
std::ostream & operator<<(std::ostream &lout, WindowLogColor m)
int sync()
This is called to flush the buffer of the streaming devices.
std::string GetSizeStr() const
void Display(bool empty=false)
Display backlog.
WindowLogAttrs
Stream manipulators to change the attributes of a WindowLog stream.
bool OpenLogFile(const std::string &filename, bool append=false)
Open a log-file.