YARP
Yet Another Robot Platform
YarpLogger.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <iostream>
10 #include <cstring>
11 #include <string>
12 #include <sstream>
13 #include <cstdio>
14 #include <fstream>
15 #include <iterator>
16 #include <yarp/os/RpcClient.h>
17 #include <yarp/os/SystemClock.h>
18 #include <yarp/logger/YarpLogger.h>
19 
20 using namespace yarp::os;
21 using namespace yarp::yarpLogger;
22 using namespace std;
23 /*
24 const std::string RED ="\033[01;31m";
25 const std::string GREEN ="\033[01;32m";
26 const std::string YELLOW ="\033[01;33m";
27 const std::string BLUE ="\033[01;34m";
28 const std::string CLEAR ="\033[00m";
29 
30 const std::string RED_ERROR = RED+"ERROR"+CLEAR;
31 const std::string YELLOW_WARNING = YELLOW+"WARNING"+CLEAR;
32 */
33 void LogEntry::clear_logEntries()
34 {
35  entry_list.clear();
36  logInfo.clear();
37  last_read_message=-1;
38 }
39 
40 void LogEntry::setLogEntryMaxSize(int size)
41 {
42  entry_list_max_size = size;
43  entry_list.reserve(entry_list_max_size);
44  clear_logEntries();
45 }
46 
47 void LogEntry::setLogEntryMaxSizeEnabled (bool enable)
48 {
49  entry_list_max_size_enabled=enable;
50 }
51 
52 bool LogEntry::append_logEntry(MessageEntry entry)
53 {
54  if (logInfo.logsize >= entry_list_max_size && entry_list_max_size_enabled)
55  {
56  //printf("WARNING: exceeded entry_list_max_size=%d\n",entry_list_max_size);
57  return false;
58  }
59  entry_list.push_back(entry);
60  logInfo.logsize++;
61  return true;
62 }
63 
64 void LogEntryInfo::clear()
65 {
66  logsize=0;
67  number_of_traces=0;
68  number_of_debugs=0;
69  number_of_infos=0;
70  number_of_warnings=0;
71  number_of_errors=0;
72  number_of_fatals=0;
73  highest_error=LOGLEVEL_UNDEFINED;
74  last_update=-1;
75 }
76 
77 LogLevel LogEntryInfo::getLastError()
78 {
79  return highest_error;
80 }
81 
82 void LogEntryInfo::clearLastError()
83 {
84  highest_error=LOGLEVEL_UNDEFINED;
85 }
86 
87 void LogEntryInfo::setNewError(LogLevel level)
88 {
89  if (level==LOGLEVEL_TRACE) number_of_traces++;
90  else if (level==LOGLEVEL_DEBUG) number_of_debugs++;
91  else if (level==LOGLEVEL_INFO) number_of_infos++;
92  else if (level==LOGLEVEL_WARNING) number_of_warnings++;
93  else if (level==LOGLEVEL_ERROR) number_of_errors++;
94  else if (level==LOGLEVEL_FATAL) number_of_fatals++;
95  if (level>highest_error) highest_error=level;
96 }
97 
98 void LoggerEngine::discover (std::list<std::string>& ports)
99 {
100  RpcClient p;
101  string logger_portname = log_updater->getPortName();
102  p.open(logger_portname+"/discover");
103  std::string yarpservername = yarp::os::Network::getNameServerName();
104  yarp::os::Network::connect(logger_portname+"/discover",yarpservername);
105  Bottle cmd,response;
106  cmd.addString("bot");
107  cmd.addString("list");
108  p.write(cmd,response);
109  printf ("%s\n\n", response.toString().c_str());
110  int size = response.size();
111  for (int i=1; i<size; i++) //beware: skip i=0 is intentional!
112  {
113  Bottle* n1 = response.get(i).asList();
114  if (n1 && n1->get(0).toString()=="port")
115  {
116  Bottle* n2 = n1->get(1).asList();
117  if (n2 && n2->get(0).toString()=="name")
118  {
119  char* log_off = nullptr;
120  char* yarprun_log_off = nullptr;
121  log_off = std::strstr((char*)(n2->get(1).toString().c_str()), "/log/");
122  if (log_off)
123  {
124  std::string logport = n2->get(1).toString();
125  printf ("%s\n", logport.c_str());
126  ports.push_back(logport);
127  }
128  yarprun_log_off = std::strstr((char*)(n2->get(1).toString().c_str()), "/yarprunlog/");
129  if (yarprun_log_off)
130  {
131  std::string logport = n2->get(1).toString();
132  printf ("%s\n", logport.c_str());
133  ports.push_back(logport);
134  }
135  }
136  }
137  }
138 
139  std::list<std::string>::iterator ports_it;
140  for (ports_it=ports.begin(); ports_it!=ports.end(); ports_it++)
141  {
142  LogEntry entry;
143  entry.logInfo.port_complete = (*ports_it);
145  if (contact.isValid())
146  {
147  entry.logInfo.ip_address = contact.getHost();
148  }
149  else
150  {
151  printf("ERROR: invalid contact: %s\n", entry.logInfo.port_complete.c_str());
152  }
153  std::istringstream iss(*ports_it);
154  std::string token;
155  getline(iss, token, '/');
156  getline(iss, token, '/');
157  getline(iss, token, '/'); entry.logInfo.port_prefix = "/"+ token;
158  getline(iss, token, '/'); entry.logInfo.process_name = token;
159  getline(iss, token, '/'); entry.logInfo.process_pid = token;
160 
161  std::list<LogEntry>::iterator it;
162  this->log_updater->mutex.lock();
163  bool found = false;
164  for (it = this->log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
165  {
166  if (it->logInfo.port_complete==entry.logInfo.port_complete)
167  {
168  found=true; break;
169  }
170  }
171  if (found==false)
172  {
173  log_updater->log_list.push_back(entry);
174  }
175  this->log_updater->mutex.unlock();
176  }
177 }
178 
179 void LoggerEngine::connect (const std::list<std::string>& ports)
180 {
182  style.timeout=1.0;
183  style.quiet=true;
184 
185  std::list<std::string>::const_iterator it;
186  for (it = ports.begin(); it != ports.end(); it++)
187  {
188  if (yarp::os::Network::exists(*it,style) == true)
189  {
190  yarp::os::Network::connect(*it,this->log_updater->getPortName());
191  }
192  else
193  {
194  //fprintf(stderr,"unable to connect to port %s\n",it->c_str());
195  }
196  }
197 }
198 
199 std::string LoggerEngine::logger_thread::getPortName()
200 {
201  return logger_portName;
202 }
203 
204 LoggerEngine::logger_thread::logger_thread (std::string _portname, double _period, int _log_list_max_size) : PeriodicThread(_period, ShouldUseSystemClock::Yes)
205 {
206  logger_portName = _portname;
207  log_list_max_size = _log_list_max_size;
208  log_list_max_size_enabled = true;
209  listen_to_LOGLEVEL_UNDEFINED = true;
210  listen_to_LOGLEVEL_TRACE = true;
211  listen_to_LOGLEVEL_DEBUG = true;
212  listen_to_LOGLEVEL_INFO = true;
213  listen_to_LOGLEVEL_WARNING = true;
214  listen_to_LOGLEVEL_ERROR = true;
215  listen_to_LOGLEVEL_FATAL = true;
216  listen_to_YARP_MESSAGES = true;
217  listen_to_YARPRUN_MESSAGES = true;
218  unknown_format_received = 0;
219 }
220 
221 void LoggerEngine::logger_thread::run()
222 {
223  //if (is_discovering()==true)
224  {
225  //yarp::os::Network::
226  }
227 
228  //yarp::os::SystemClock::delaySystem(0.001);
229  //if (logger_port.getInputCount()>0)
230  {
231  int bufferport_size = logger_port.getPendingReads();
232 
233  while (bufferport_size>0)
234  {
235  std::time_t machine_current_time = std::time(nullptr);
236  char machine_current_time_c [50];
237  //strftime(machine_current_time_s, 20, "%Y-%m-%d %H:%M:%S", localtime(&machine_current_time));
238  static double d_time_i = yarp::os::SystemClock::nowSystem();
239  double d_time = yarp::os::SystemClock::nowSystem() - d_time_i;
240  sprintf(machine_current_time_c,"%f",d_time);
241  string machine_current_time_s = string(machine_current_time_c);
242 
243  Bottle *b = logger_port.read(); //this is blocking
244  bufferport_size = logger_port.getPendingReads();
245 
246  if (b==nullptr)
247  {
248  fprintf (stderr, "ERROR: something strange happened here, bufferport_size = %d!\n",bufferport_size);
249  return;
250  }
251 
252  if (b->size()!=2)
253  {
254  fprintf (stderr, "ERROR: unknown log format!\n");
255  unknown_format_received++;
256  continue;
257  }
258 
259  std::string bottlestring = b->toString();
260  std::string header;
261 
262  if (b->get(0).isString())
263  {
264  header = b->get(0).asString();
265  }
266  else
267  {
268  fprintf(stderr, "ERROR: unknown log format!\n");
269  unknown_format_received++;
270  continue;
271  }
272 
273  MessageEntry body;
274 
275  char ttstr [20];
276  static int count=0;
277  sprintf(ttstr,"%d",count++);
278  body.yarprun_timestamp = string(ttstr);
279  body.local_timestamp = machine_current_time_s;
280 
281  std::string s;
282 
283  if (b->get(1).isString())
284  {
285  s = b->get(1).asString();
286  }
287  else
288  {
289  fprintf(stderr, "ERROR: unknown log format!\n");
290  unknown_format_received++;
291  continue;
292  }
293 
294  yarp::os::Property p(s.c_str());
295 
296  if (p.check("level")) {
297  body.text = p.find("message").toString();
298 
299  auto level = p.find("level").toString();
300  if (level == "TRACE") {
301  body.level = LOGLEVEL_TRACE;
302  } else if (level == "DEBUG") {
303  body.level = LOGLEVEL_DEBUG;
304  } else if (level == "INFO") {
305  body.level = LOGLEVEL_INFO;
306  } else if (level == "WARNING") {
307  body.level = LOGLEVEL_WARNING;
308  } else if (level == "ERROR") {
309  body.level = LOGLEVEL_ERROR;
310  } else if (level == "FATAL") {
311  body.level = LOGLEVEL_FATAL;
312  } else {
313  body.level = LOGLEVEL_UNDEFINED;
314  }
315 
316  if (p.check("filename")) {
317  body.filename = p.find("filename").asString();
318  } else {
319  body.filename.clear();
320  }
321 
322  if (p.check("line")) {
323  body.line = static_cast<uint32_t>(p.find("line").asInt32());
324  } else {
325  body.line = 0;
326  }
327 
328  if (p.check("function")) {
329  body.function = p.find("function").asString();
330  } else {
331  body.function.clear();
332  }
333 
334  if (p.check("hostname")) {
335  body.hostname = p.find("hostname").asString();
336  } else {
337  body.hostname.clear();
338  }
339 
340  if (p.check("pid")) {
341  body.pid = p.find("pid").asInt32();
342  } else {
343  body.pid = 0;
344  }
345 
346  if (p.check("cmd")) {
347  body.cmd = p.find("cmd").asString();
348  } else {
349  body.cmd.clear();
350  }
351 
352  if (p.check("args")) {
353  body.args = p.find("args").asString();
354  } else {
355  body.args.clear();
356  }
357 
358  if (p.check("thread_id")) {
359  body.thread_id = p.find("thread_id").asInt64();
360  } else {
361  body.thread_id = 0;
362  }
363 
364  if (p.check("component")) {
365  body.component = p.find("component").asString();
366  } else {
367  body.component.clear();
368  }
369 
370  if (p.check("systemtime")) {
371  body.systemtime = p.find("systemtime").asFloat64();
372  } else {
373  body.systemtime = 0.0;
374  }
375 
376  if (p.check("networktime")) {
377  body.networktime = p.find("networktime").asFloat64();
378  } else {
379  body.networktime = body.systemtime;
380  body.yarprun_timestamp.clear();
381  }
382 
383  if (p.check("externaltime")) {
384  body.externaltime = p.find("externaltime").asFloat64();
385  } else {
386  body.externaltime = 0.0;
387  }
388 
389  if (p.check("backtrace")) {
390  body.backtrace = p.find("backtrace").asString();
391  } else {
392  body.backtrace.clear();
393  }
394  } else {
395  // This is plain output forwarded by yarprun
396  // Perhaps at some point yarprun could be formatting it properly
397  // But for now we just try to extract the level information
398  body.text = s;
399  body.level = LOGLEVEL_UNDEFINED;
400 
401  size_t str = s.find('[',0);
402  size_t end = s.find(']',0);
403  if (str==std::string::npos || end==std::string::npos )
404  {
405  body.level = LOGLEVEL_UNDEFINED;
406  }
407  else if (str==0)
408  {
409  std::string level = s.substr(str,end+1);
410  body.level = LOGLEVEL_UNDEFINED;
411  if (level.find("TRACE")!=std::string::npos) body.level = LOGLEVEL_TRACE;
412  else if (level.find("DEBUG")!=std::string::npos) body.level = LOGLEVEL_DEBUG;
413  else if (level.find("INFO")!=std::string::npos) body.level = LOGLEVEL_INFO;
414  else if (level.find("WARNING")!=std::string::npos) body.level = LOGLEVEL_WARNING;
415  else if (level.find("ERROR")!=std::string::npos) body.level = LOGLEVEL_ERROR;
416  else if (level.find("FATAL")!=std::string::npos) body.level = LOGLEVEL_FATAL;
417  body.text = s.substr(end+1);
418  }
419  else
420  {
421  body.level = LOGLEVEL_UNDEFINED;
422  }
423  }
424 
425  if (body.level == LOGLEVEL_UNDEFINED && listen_to_LOGLEVEL_UNDEFINED == false) {continue;}
426  if (body.level == LOGLEVEL_TRACE && listen_to_LOGLEVEL_TRACE == false) {continue;}
427  if (body.level == LOGLEVEL_DEBUG && listen_to_LOGLEVEL_DEBUG == false) {continue;}
428  if (body.level == LOGLEVEL_INFO && listen_to_LOGLEVEL_INFO == false) {continue;}
429  if (body.level == LOGLEVEL_WARNING && listen_to_LOGLEVEL_WARNING == false) {continue;}
430  if (body.level == LOGLEVEL_ERROR && listen_to_LOGLEVEL_ERROR == false) {continue;}
431  if (body.level == LOGLEVEL_FATAL && listen_to_LOGLEVEL_FATAL == false) {continue;}
432 
433  this->mutex.lock();
434  LogEntry entry;
435  entry.logInfo.port_complete = header;
436  entry.logInfo.port_complete.erase(0,1);
437  entry.logInfo.port_complete.erase(entry.logInfo.port_complete.size()-1);
438  std::istringstream iss(header);
439  std::string token;
440  getline(iss, token, '/');
441  getline(iss, token, '/'); entry.logInfo.port_system = token;
442  getline(iss, token, '/'); entry.logInfo.port_prefix = "/"+ token;
443  getline(iss, token, '/'); entry.logInfo.process_name = token;
444  getline(iss, token, '/'); entry.logInfo.process_pid = token.erase(token.size()-1);
445  if (entry.logInfo.port_system == "log" && listen_to_YARP_MESSAGES==false) continue;
446  if (entry.logInfo.port_system == "yarprunlog" && listen_to_YARPRUN_MESSAGES==false) continue;
447 
448  std::list<LogEntry>::iterator it;
449  for (it = log_list.begin(); it != log_list.end(); it++)
450  {
451  if (it->logInfo.port_complete==entry.logInfo.port_complete)
452  {
453  if (it->logging_enabled)
454  {
455  it->logInfo.setNewError(body.level);
456  it->logInfo.last_update=machine_current_time;
457  it->append_logEntry(body);
458  }
459  else
460  {
461  //just skipping this message
462  }
463  break;
464  }
465  }
466  if (it == log_list.end())
467  {
468  if (log_list.size() < log_list_max_size || log_list_max_size_enabled==false )
469  {
471  if (contact.isValid())
472  {
473  entry.logInfo.setNewError(body.level);
474  entry.logInfo.ip_address = contact.getHost();
475  }
476  else
477  {
478  printf("ERROR: invalid contact: %s\n", entry.logInfo.port_complete.c_str());
479  };
480  entry.append_logEntry(body);
481  entry.logInfo.last_update=machine_current_time;
482  log_list.push_back(entry);
483  }
484  //else
485  //{
486  // printf("WARNING: exceeded log_list_max_size=%d\n",log_list_max_size);
487  //}
488  }
489 
490  this->mutex.unlock();
491  }
492  }
493 
494 }
495 
496 //public methods
498 {
499  if (logging == true)
500  {
501  fprintf(stderr,"logger is already running, listening on port %s\n", log_updater->getPortName().c_str());
502  return true;
503  }
504 
505  if (yarp::os::Network::exists(log_updater->getPortName()))
506  {
507  fprintf(stderr, "Unable to start logger: port %s is unavailable because another instance of the logger is already running (or address conflict)\n", log_updater->getPortName().c_str());
508  return false;
509  }
510 
511  if (log_updater->logger_port.open(log_updater->getPortName()))
512  {
513  fprintf(stdout,"Logger successfully started, listening on port %s\n", log_updater->getPortName().c_str());
514  }
515  else
516  {
517  fprintf(stderr,"Unable to start logger: port %s is unavailable\n", log_updater->getPortName().c_str());
518  return false;
519  }
520  log_updater->logger_port.resume();
521  log_updater->logger_port.setStrict();
522  logging=true;
523  log_updater->start();
524  return true;
525 }
526 
527 void LoggerEngine::logger_thread::threadRelease()
528 {
529  logger_port.interrupt();
530  logger_port.close();
531 }
532 
534 {
535  if (log_updater == nullptr) return false;
536 
537  logging=false;
538  if (log_updater->isRunning()==true) log_updater->stop();
539  return true;
540 }
541 
543 {
544  if (log_updater == nullptr) return;
545 
546  log_updater->start();
547  discovering=true;
548 }
549 
551 {
552  discovering=false;
553 }
554 
555 LoggerEngine::LoggerEngine(std::string portName)
556 {
557  log_updater=new logger_thread (portName, 0.01);
558  logging = false;
559  discovering = false;
560 }
561 
563 {
564  this->stop_logging();
565  if (log_updater!=nullptr)
566  {
567  delete log_updater;
568  log_updater = nullptr;
569  }
570 }
571 
573 {
574  if (log_updater == nullptr) return 0;
575 
576  return log_updater->logger_port.getInputCount();
577 }
578 
579 void LoggerEngine::get_infos (std::list<LogEntryInfo>& infos)
580 {
581  if (log_updater == nullptr) return;
582 
583  log_updater->mutex.lock();
584  std::list<LogEntry>::iterator it;
585  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
586  {
587  infos.push_back(it->logInfo);
588  }
589  log_updater->mutex.unlock();
590 }
591 
592 void LoggerEngine::get_messages (std::list<MessageEntry>& messages)
593 {
594  if (log_updater == nullptr) return;
595 
596  log_updater->mutex.lock();
597  std::list<LogEntry>::iterator it;
598  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
599  {
600  messages.insert(messages.end(), it->entry_list.begin(), it->entry_list.end());
601  }
602  log_updater->mutex.unlock();
603 }
604 
605 void LoggerEngine::get_messages_by_port_prefix (std::string port, std::list<MessageEntry>& messages, bool from_beginning)
606 {
607  if (log_updater == nullptr) return;
608 
609  log_updater->mutex.lock();
610  std::list<LogEntry>::iterator it;
611  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
612  {
613  if (it->logInfo.port_prefix == port)
614  {
615  //messages = (it->entry_list);
616  if (it->last_read_message==-1)
617  {
618  from_beginning=true;
619  }
620  if (from_beginning==true)
621  {
622  it->last_read_message = 0;
623  }
624  int i=it->last_read_message;
625  for (; i<(int)it->entry_list.size(); i++)
626  {
627  messages.push_back(it->entry_list[i]);
628  }
629  it->last_read_message=i;
630  break;
631  }
632  }
633  log_updater->mutex.unlock();
634 }
635 
637 {
638  if (log_updater == nullptr) return;
639 
640  log_updater->mutex.lock();
641  std::list<LogEntry>::iterator it;
642  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
643  {
644  if (it->logInfo.port_complete == port)
645  {
646  it->clear_logEntries();
647  break;
648  }
649  }
650  log_updater->mutex.unlock();
651 }
652 
653 void LoggerEngine::get_messages_by_port_complete (std::string port, std::list<MessageEntry>& messages, bool from_beginning)
654 {
655  if (log_updater == nullptr) return;
656 
657  log_updater->mutex.lock();
658  std::list<LogEntry>::iterator it;
659  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
660  {
661  if (it->logInfo.port_complete == port)
662  {
663  //messages = (it->entry_list);
664  if (it->last_read_message==-1)
665  {
666  from_beginning=true;
667  }
668  if (from_beginning==true)
669  {
670  it->last_read_message = 0;
671  }
672  int i=it->last_read_message;
673  int size = (int)it->entry_list.size();
674  for (; i<size; i++)
675  {
676  messages.push_back(it->entry_list[i]);
677  }
678  it->last_read_message=i;
679  break;
680  }
681  }
682  log_updater->mutex.unlock();
683 }
684 
685 void LoggerEngine::get_messages_by_process (std::string process, std::list<MessageEntry>& messages, bool from_beginning)
686 {
687  if (log_updater == nullptr) return;
688 
689  log_updater->mutex.lock();
690  std::list<LogEntry>::iterator it;
691  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
692  {
693  if (it->logInfo.process_name == process)
694  {
695  //messages = (it->entry_list);
696  if (it->last_read_message==-1)
697  {
698  from_beginning=true;
699  }
700  if (from_beginning==true)
701  {
702  it->last_read_message = 0;
703  }
704  int i=it->last_read_message;
705  for (; i<(int)it->entry_list.size(); i++)
706  {
707  messages.push_back(it->entry_list[i]);
708  }
709  it->last_read_message=i;
710  break;
711  }
712  }
713  log_updater->mutex.unlock();
714 }
715 
716 void LoggerEngine::get_messages_by_pid (std::string pid, std::list<MessageEntry>& messages, bool from_beginning)
717 {
718  if (log_updater == nullptr) return;
719 
720  log_updater->mutex.lock();
721  std::list<LogEntry>::iterator it;
722  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
723  {
724  if (it->logInfo.process_pid == pid)
725  {
726  //messages = (it->entry_list);
727  if (it->last_read_message==-1)
728  {
729  from_beginning=true;
730  }
731  if (from_beginning==true)
732  {
733  it->last_read_message = 0;
734  }
735  int i=it->last_read_message;
736  for (; i<(int)it->entry_list.size(); i++)
737  {
738  messages.push_back(it->entry_list[i]);
739  }
740  it->last_read_message=i;
741  break;
742  }
743  }
744  log_updater->mutex.unlock();
745 }
746 
747 const std::list<MessageEntry> filter_by_level (int level, const std::list<MessageEntry>& messages)
748 {
749  std::list<MessageEntry> ret;
750  std::list<MessageEntry>::const_iterator it;
751  for (it = messages.begin(); it != messages.end(); it++)
752  {
753  LogLevel llevel = it->level;
754  if (llevel.toInt() == level)
755  ret.push_back(*it);
756  }
757  return ret;
758 }
759 
760 void LoggerEngine::set_listen_option (LogLevel logLevel, bool enable)
761 {
762  if (log_updater == nullptr) return;
763  log_updater->mutex.lock();
764  if (logLevel == LOGLEVEL_UNDEFINED) {log_updater->listen_to_LOGLEVEL_UNDEFINED=enable;}
765  else if (logLevel == LOGLEVEL_TRACE) {log_updater->listen_to_LOGLEVEL_TRACE=enable;}
766  else if (logLevel == LOGLEVEL_INFO) {log_updater->listen_to_LOGLEVEL_INFO=enable;}
767  else if (logLevel == LOGLEVEL_DEBUG) {log_updater->listen_to_LOGLEVEL_DEBUG=enable;}
768  else if (logLevel == LOGLEVEL_WARNING) {log_updater->listen_to_LOGLEVEL_WARNING=enable;}
769  else if (logLevel == LOGLEVEL_ERROR) {log_updater->listen_to_LOGLEVEL_ERROR=enable;}
770  else if (logLevel == LOGLEVEL_FATAL) {log_updater->listen_to_LOGLEVEL_FATAL=enable;}
771  log_updater->mutex.unlock();
772 }
773 
775 {
776  if (log_updater == nullptr) return false;
777  if (logLevel == LOGLEVEL_UNDEFINED) {return log_updater->listen_to_LOGLEVEL_UNDEFINED;}
778  if (logLevel == LOGLEVEL_TRACE) {return log_updater->listen_to_LOGLEVEL_TRACE;}
779  if (logLevel == LOGLEVEL_DEBUG) {return log_updater->listen_to_LOGLEVEL_DEBUG;}
780  if (logLevel == LOGLEVEL_INFO) {return log_updater->listen_to_LOGLEVEL_INFO;}
781  if (logLevel == LOGLEVEL_WARNING) {return log_updater->listen_to_LOGLEVEL_WARNING;}
782  if (logLevel == LOGLEVEL_ERROR) {return log_updater->listen_to_LOGLEVEL_ERROR;}
783  if (logLevel == LOGLEVEL_FATAL) {return log_updater->listen_to_LOGLEVEL_FATAL;}
784  return false;
785 }
786 
787 void LoggerEngine::set_listen_option (std::string option, bool enable)
788 {
789  if (log_updater == nullptr) return;
790  log_updater->mutex.lock();
791  log_updater->mutex.unlock();
792 }
793 
794 bool LoggerEngine::get_listen_option (std::string option)
795 {
796  return false;
797 }
798 
799 void LoggerEngine::set_listen_option (LogSystemEnum logSystem, bool enable)
800 {
801  if (log_updater == nullptr) return;
802  log_updater->mutex.lock();
803  if (logSystem == LOGSYSTEM_YARP) {log_updater->listen_to_YARP_MESSAGES=enable;}
804  else if (logSystem == LOGSYSTEM_YARPRUN) {log_updater->listen_to_YARPRUN_MESSAGES=enable;}
805  log_updater->mutex.unlock();
806 }
807 
809 {
810  if (log_updater == nullptr) return false;
811  if (logSystem == LOGSYSTEM_YARP) {return log_updater->listen_to_YARP_MESSAGES;}
812  if (logSystem == LOGSYSTEM_YARPRUN) {return log_updater->listen_to_YARPRUN_MESSAGES;}
813  return false;
814 }
815 
816 bool LoggerEngine::export_log_to_text_file (std::string filename, std::string portname)
817 {
818  if (log_updater == nullptr) return false;
819  if (filename.size() == 0) return false;
820 
821  log_updater->mutex.lock();
822  std::list<LogEntry>::iterator it;
823  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
824  {
825  if (it->logInfo.port_complete == portname)
826  {
827  ofstream file1;
828  file1.open(filename.c_str());
829  if (file1.is_open() == false) {log_updater->mutex.unlock(); return false;}
830  std::vector<MessageEntry>::iterator it1;
831  for (it1 = it->entry_list.begin(); it1 != it->entry_list.end(); it1++)
832  {
833  file1 << it1->yarprun_timestamp << " " << it1->local_timestamp << " " << it1->level.toString() << " " << it1->text << " " << std::endl;
834  }
835  file1.close();
836  }
837  }
838  log_updater->mutex.unlock();
839  return true;
840 }
841 
842 bool LoggerEngine::save_all_logs_to_file (std::string filename)
843 {
844  string start_string ="<#STRING_START#>";
845  string end_string ="<#STRING_END#>";
846 
847  if (log_updater == nullptr) return false;
848  if (filename.size() == 0) return false;
849 
850  const int LOGFILE_VERSION = 1;
851 
852  ofstream file1;
853  file1.open(filename.c_str());
854  if (file1.is_open() == false) return false;
855 
856  bool wasRunning = log_updater->isRunning();
857  if (wasRunning) log_updater->stop();
858  std::list<LogEntry>::iterator it;
859  file1 << LOGFILE_VERSION << std::endl;
860  file1 << log_updater->log_list.size() << std::endl;
861  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
862  {
863  file1 << it->logInfo.ip_address << std::endl;
864  file1 << it->logInfo.port_complete << std::endl;
865  file1 << it->logInfo.port_prefix << std::endl;
866  file1 << it->logInfo.port_system << std::endl;
867  file1 << it->logInfo.process_name << std::endl;
868  file1 << it->logInfo.process_pid << std::endl;
869  file1 << it->logInfo.get_number_of_traces() << std::endl;
870  file1 << it->logInfo.get_number_of_debugs() << std::endl;
871  file1 << it->logInfo.get_number_of_infos() << std::endl;
872  file1 << it->logInfo.get_number_of_warnings() << std::endl;
873  file1 << it->logInfo.get_number_of_errors() << std::endl;
874  file1 << it->logInfo.get_number_of_fatals() << std::endl;
875  file1 << it->logInfo.logsize << std::endl;
876  file1 << it->entry_list.size() << std::endl;
877  std::vector<MessageEntry>::iterator it1;
878  for (it1 = it->entry_list.begin(); it1 != it->entry_list.end(); it1++)
879  {
880  file1 << it1->yarprun_timestamp << std::endl;
881  file1 << it1->local_timestamp << std::endl;
882  file1 << it1->level.toInt() << std::endl;
883  file1 << start_string;
884  for (char s : it1->text) file1.put(s);
885  file1 << end_string <<endl;
886  }
887  }
888  file1.close();
889  if (wasRunning) log_updater->start();
890  return true;
891 }
892 
893 std::streamoff get_tag(ifstream& file, const char* tag)
894 {
895  std::streamoff pos=file.tellg();
896  int tag_size=strlen(tag);
897  char* buff = new char[tag_size+2];
898  for(int i=0; i<tag_size+2;i++) buff[i]=0;
899  std::streamoff off=0;
900  for (; ;off++)
901  {
902  file.seekg(pos+off);
903  file.read(buff,tag_size);
904  if (file.good()==false)
905  {
906  delete [] buff;
907  return -1;
908  }
909  if (strcmp(buff,tag)==0) break;
910  }
911  delete [] buff;
912  return pos+off;
913 }
914 
915 bool LoggerEngine::load_all_logs_from_file (std::string filename)
916 {
917  string start_string ="<#STRING_START#>";
918  int start_string_size=strlen(start_string.c_str());
919  string end_string ="<#STRING_END#>";
920  int end_string_size=strlen(end_string.c_str());
921 
922  if (log_updater == nullptr) return false;
923  if (filename.size() == 0) return false;
924 
925  const int LOGFILE_VERSION = 1;
926 
927  ifstream file1;
928  file1.open(filename.c_str(),std::ifstream::binary);
929  if (file1.is_open() == false) return false;
930 
931  int log_file_version;
932  bool wasRunning = log_updater->isRunning();
933  if (wasRunning) log_updater->stop();
934  file1 >> log_file_version;
935  if (log_file_version == LOGFILE_VERSION)
936  {
937  int size_log_list;
938  file1 >> size_log_list;
939  log_updater->log_list.clear();
940  for (int i=0; i< size_log_list; i++)
941  {
942  LogEntry l_tmp;
943  int dummy;
944  file1 >> l_tmp.logInfo.ip_address;
945  file1 >> l_tmp.logInfo.port_complete;
946  file1 >> l_tmp.logInfo.port_prefix;
947  file1 >> l_tmp.logInfo.port_system;
948  file1 >> l_tmp.logInfo.process_name;
949  file1 >> l_tmp.logInfo.process_pid;
950  file1 >> dummy; //l_tmp.logInfo.number_of_traces;
951  file1 >> dummy; //l_tmp.logInfo.number_of_debugs;
952  file1 >> dummy; //l_tmp.logInfo.number_of_infos;
953  file1 >> dummy; //l_tmp.logInfo.number_of_warning;
954  file1 >> dummy; //l_tmp.logInfo.number_of_errors;
955  file1 >> dummy; //l_tmp.logInfo.number_of_fatals;
956  file1 >> l_tmp.logInfo.logsize;
957  int size_entry_list;
958  file1 >> size_entry_list;
959  for (int j=0; j< size_entry_list; j++)
960  {
961  MessageEntry m_tmp;
962  file1 >> m_tmp.yarprun_timestamp;
963  file1 >> m_tmp.local_timestamp;
964  int tmp_level;
965  file1 >> tmp_level;
966  m_tmp.level.setLevel(tmp_level);
967  std::streamoff start_p = get_tag(file1, start_string.c_str());
968  std::streamoff end_p = get_tag(file1, end_string.c_str());
969  //validity check
970  if (start_p<0 || end_p<0 || end_p-start_p+start_string_size<=0) return false;
971  char *buff = new char[(unsigned int)(end_p-start_p+start_string_size)];
972  //memset(buff,0,end_p-start_p+start_string_size);
973  file1.seekg(start_p+start_string_size);
974  if (end_p-start_p-start_string_size!=1)
975  {
976  file1.get(buff,end_p-start_p-start_string_size);
977  }
978  else
979  {
980  //skip empty strings
981  }
982  file1.seekg(end_p+end_string_size);
983  m_tmp.text=buff;
984  delete [] buff;
985  l_tmp.entry_list.push_back(m_tmp);
986  }
987  log_updater->log_list.push_back(l_tmp);
988  }
989  }
990  file1.close();
991  if (wasRunning) log_updater->start();
992  return true;
993 }
994 
995 void LoggerEngine::set_log_lines_max_size (bool enabled, int new_size)
996 {
997  if (log_updater == nullptr) return;
998  log_updater->mutex.lock();
999 
1000  std::list<LogEntry>::iterator it;
1001  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
1002  {
1003  it->setLogEntryMaxSize(new_size);
1004  it->setLogEntryMaxSizeEnabled(enabled);
1005  }
1006 
1007  log_updater->mutex.unlock();
1008 }
1009 
1010 
1011 void LoggerEngine::set_log_list_max_size (bool enabled, int new_size)
1012 {
1013  if (log_updater == nullptr) return;
1014  log_updater->mutex.lock();
1015  log_updater->log_list_max_size_enabled = enabled;
1016  log_updater->log_list_max_size = new_size;
1017  log_updater->mutex.unlock();
1018 }
1019 
1020 void LoggerEngine::get_log_lines_max_size (bool& enabled, int& current_size)
1021 {
1022  if (log_updater == nullptr) return;
1023  if (log_updater->log_list.empty() == true) return;
1024  log_updater->mutex.lock();
1025  auto it = log_updater->log_list.begin();
1026  current_size = it->getLogEntryMaxSize();
1027  enabled = it->getLogEntryMaxSizeEnabled();
1028  log_updater->mutex.unlock();
1029 }
1030 
1031 void LoggerEngine::get_log_list_max_size (bool& enabled, int& current_size)
1032 {
1033  if (log_updater == nullptr) return;
1034  log_updater->mutex.lock();
1035  enabled=log_updater->log_list_max_size_enabled;
1036  current_size=log_updater->log_list_max_size;
1037  log_updater->mutex.unlock();
1038 }
1039 
1041 {
1042  if (log_updater == nullptr) return false;
1043  log_updater->mutex.lock();
1044  log_updater->log_list.clear();
1045  log_updater->mutex.unlock();
1046  return true;
1047 }
1048 
1049 void LoggerEngine::set_log_enable_by_port_complete (std::string port, bool enable)
1050 {
1051  if (log_updater == nullptr) return;
1052 
1053  log_updater->mutex.lock();
1054  std::list<LogEntry>::iterator it;
1055  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
1056  {
1057  if (it->logInfo.port_complete == port)
1058  {
1059  it->logging_enabled=enable;
1060  break;
1061  }
1062  }
1063  log_updater->mutex.unlock();
1064 }
1065 
1067 {
1068  if (log_updater == nullptr) return false;
1069 
1070  bool enabled=false;
1071  log_updater->mutex.lock();
1072  std::list<LogEntry>::iterator it;
1073  for (it = log_updater->log_list.begin(); it != log_updater->log_list.end(); it++)
1074  {
1075  if (it->logInfo.port_complete == port)
1076  {
1077  enabled=it->logging_enabled;
1078  break;
1079  }
1080  }
1081  log_updater->mutex.unlock();
1082  return enabled;
1083 }
yarp::yarpLogger::LoggerEngine::start_logging
bool start_logging()
Definition: YarpLogger.cpp:497
yarp::yarpLogger::LogEntryInfo::process_pid
std::string process_pid
Definition: YarpLogger.h:157
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::yarpLogger::LOGLEVEL_FATAL
@ LOGLEVEL_FATAL
Definition: YarpLogger.h:45
YarpLogger.h
yarp::os::Bottle::toString
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:214
SystemClock.h
yarp::os::ShouldUseSystemClock::No
@ No
yarp::yarpLogger::LOGLEVEL_INFO
@ LOGLEVEL_INFO
Definition: YarpLogger.h:42
yarp::os::ContactStyle
Preferences for how to communicate with a contact.
Definition: ContactStyle.h:27
yarp::yarpLogger::MessageEntry::function
std::string function
Definition: YarpLogger.h:126
yarp::yarpLogger::LoggerEngine::clear_messages_by_port_complete
void clear_messages_by_port_complete(std::string port)
Definition: YarpLogger.cpp:636
yarp::yarpLogger::LOGLEVEL_WARNING
@ LOGLEVEL_WARNING
Definition: YarpLogger.h:43
yarp::os::Bottle::size
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
yarp::yarpLogger::MessageEntry::yarprun_timestamp
std::string yarprun_timestamp
Definition: YarpLogger.h:137
yarp::yarpLogger::LogEntryInfo::process_name
std::string process_name
Definition: YarpLogger.h:156
yarp::yarpLogger::LOGLEVEL_UNDEFINED
@ LOGLEVEL_UNDEFINED
Definition: YarpLogger.h:39
yarp::yarpLogger::MessageEntry::systemtime
double systemtime
Definition: YarpLogger.h:133
yarp::yarpLogger::LoggerEngine::export_log_to_text_file
bool export_log_to_text_file(std::string filename, std::string portname)
Definition: YarpLogger.cpp:816
yarp::yarpLogger::LogEntryInfo::port_system
std::string port_system
Definition: YarpLogger.h:153
yarp::yarpLogger::LogSystemEnum
LogSystemEnum
Definition: YarpLogger.h:113
yarp::yarpLogger::MessageEntry::line
unsigned int line
Definition: YarpLogger.h:125
yarp::os::RpcClient
A port that is specialized as an RPC client.
Definition: RpcClient.h:26
yarp::yarpLogger::LoggerEngine::set_log_enable_by_port_complete
void set_log_enable_by_port_complete(std::string port, bool enable)
Definition: YarpLogger.cpp:1049
yarp::yarpLogger::LoggerEngine::clear
bool clear()
Definition: YarpLogger.cpp:1040
yarp::yarpLogger::LogEntry::entry_list
std::vector< MessageEntry > entry_list
Definition: YarpLogger.h:184
yarp::yarpLogger::LoggerEngine::get_infos
void get_infos(std::list< LogEntryInfo > &infos)
Definition: YarpLogger.cpp:579
yarp::yarpLogger::LoggerEngine::get_messages_by_process
void get_messages_by_process(std::string process, std::list< MessageEntry > &messages, bool from_beginning=false)
Definition: YarpLogger.cpp:685
ret
bool ret
Definition: ImplementAxisInfo.cpp:72
yarp::yarpLogger::MessageEntry::text
std::string text
Definition: YarpLogger.h:123
yarp::yarpLogger::MessageEntry::pid
int pid
Definition: YarpLogger.h:130
yarp::yarpLogger::LoggerEngine::get_messages_by_port_prefix
void get_messages_by_port_prefix(std::string port, std::list< MessageEntry > &messages, bool from_beginning=false)
Definition: YarpLogger.cpp:605
yarp::yarpLogger::LoggerEngine::get_num_of_processes
int get_num_of_processes()
Definition: YarpLogger.cpp:572
yarp::yarpLogger::LOGLEVEL_TRACE
@ LOGLEVEL_TRACE
Definition: YarpLogger.h:40
yarp::yarpLogger::MessageEntry::backtrace
std::string backtrace
Definition: YarpLogger.h:136
filter_by_level
const std::list< MessageEntry > filter_by_level(int level, const std::list< MessageEntry > &messages)
Definition: YarpLogger.cpp:747
yarp::os::SystemClock::nowSystem
static double nowSystem()
Definition: SystemClock.cpp:37
yarp::yarpLogger::LoggerEngine::LoggerEngine
LoggerEngine(std::string portName)
Definition: YarpLogger.cpp:555
yarp::yarpLogger::LogEntry::append_logEntry
bool append_logEntry(MessageEntry entry)
Definition: YarpLogger.cpp:52
yarp::yarpLogger::LogEntryInfo::ip_address
std::string ip_address
Definition: YarpLogger.h:158
yarp::os::Value::isString
virtual bool isString() const
Checks if value is a string.
Definition: Value.cpp:159
yarp::os::NetworkBase::queryName
static Contact queryName(const std::string &name)
Find out information about a registered name.
Definition: Network.cpp:998
yarp::yarpLogger::MessageEntry::cmd
std::string cmd
Definition: YarpLogger.h:128
yarp::yarpLogger::LoggerEngine::set_log_lines_max_size
void set_log_lines_max_size(bool enabled, int new_size)
Definition: YarpLogger.cpp:995
get_tag
std::streamoff get_tag(ifstream &file, const char *tag)
Definition: YarpLogger.cpp:893
yarp::os::AbstractContactable::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: AbstractContactable.cpp:12
yarp::yarpLogger::LogLevel
Definition: YarpLogger.h:49
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::os::ContactStyle::quiet
bool quiet
Suppress all outputs and warnings.
Definition: ContactStyle.h:39
yarp::yarpLogger::LogLevel::setLevel
void setLevel(LogLevelEnum level)
Definition: YarpLogger.h:61
yarp::yarpLogger::MessageEntry::networktime
double networktime
Definition: YarpLogger.h:134
yarp::yarpLogger::MessageEntry::level
LogLevel level
Definition: YarpLogger.h:122
yarp::yarpLogger::LogEntryInfo::setNewError
void setNewError(LogLevel level)
Definition: YarpLogger.cpp:87
yarp::yarpLogger::MessageEntry::component
std::string component
Definition: YarpLogger.h:132
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::os::NetworkBase::connect
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition: Network.cpp:685
yarp::yarpLogger::MessageEntry::args
std::string args
Definition: YarpLogger.h:129
yarp::yarpLogger::MessageEntry
Definition: YarpLogger.h:121
yarp::yarpLogger::LogEntry
Definition: YarpLogger.h:177
yarp::yarpLogger::LOGSYSTEM_YARPRUN
@ LOGSYSTEM_YARPRUN
Definition: YarpLogger.h:115
yarp::yarpLogger::MessageEntry::local_timestamp
std::string local_timestamp
Definition: YarpLogger.h:138
yarp::os::Bottle::addString
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:173
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
yarp::yarpLogger::LogEntry::logInfo
yarp::yarpLogger::LogEntryInfo logInfo
Definition: YarpLogger.h:205
yarp::yarpLogger::LogEntryInfo::port_complete
std::string port_complete
Definition: YarpLogger.h:155
yarp::yarpLogger::LOGLEVEL_DEBUG
@ LOGLEVEL_DEBUG
Definition: YarpLogger.h:41
yarp::yarpLogger::LoggerEngine::load_all_logs_from_file
bool load_all_logs_from_file(std::string filename)
Definition: YarpLogger.cpp:915
yarp::yarpLogger::MessageEntry::hostname
std::string hostname
Definition: YarpLogger.h:127
yarp::yarpLogger::LoggerEngine::get_log_lines_max_size
void get_log_lines_max_size(bool &enabled, int &current_size)
Definition: YarpLogger.cpp:1020
yarp::yarpLogger::LoggerEngine::start_discover
void start_discover()
Definition: YarpLogger.cpp:542
yarp::yarpLogger::LoggerEngine::save_all_logs_to_file
bool save_all_logs_to_file(std::string filename)
Definition: YarpLogger.cpp:842
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yarp::yarpLogger
Definition: YarpLogger.h:31
yarp::yarpLogger::LOGLEVEL_ERROR
@ LOGLEVEL_ERROR
Definition: YarpLogger.h:44
RpcClient.h
yarp::os::Contact::isValid
bool isValid() const
Checks if a Contact is tagged as valid.
Definition: Contact.cpp:301
yarp::os::ShouldUseSystemClock
ShouldUseSystemClock
Definition: Time.h:23
yarp::yarpLogger::LoggerEngine::stop_logging
bool stop_logging()
Definition: YarpLogger.cpp:533
yarp::yarpLogger::LoggerEngine::get_log_list_max_size
void get_log_list_max_size(bool &enabled, int &current_size)
Definition: YarpLogger.cpp:1031
yarp::yarpLogger::LogEntryInfo::port_prefix
std::string port_prefix
Definition: YarpLogger.h:154
yarp::yarpLogger::LoggerEngine::stop_discover
void stop_discover()
Definition: YarpLogger.cpp:550
yarp::os::Contact::getHost
std::string getHost() const
Get the host name associated with this Contact for socket communication.
Definition: Contact.cpp:231
yarp::os::Bottle::read
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition: Bottle.cpp:243
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::yarpLogger::LoggerEngine::get_messages_by_port_complete
void get_messages_by_port_complete(std::string port, std::list< MessageEntry > &messages, bool from_beginning=false)
Definition: YarpLogger.cpp:653
yarp::os::NetworkBase::getNameServerName
static std::string getNameServerName()
Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
Definition: Network.cpp:1355
yarp::os::Value::asList
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:243
yarp::yarpLogger::MessageEntry::thread_id
long thread_id
Definition: YarpLogger.h:131
yarp::yarpLogger::MessageEntry::filename
std::string filename
Definition: YarpLogger.h:124
yarp::yarpLogger::MessageEntry::externaltime
double externaltime
Definition: YarpLogger.h:135
yarp::os::ContactStyle::timeout
double timeout
Set a timeout for communication (in units of seconds, fractional seconds allowed).
Definition: ContactStyle.h:50
yarp::yarpLogger::LoggerEngine::set_listen_option
void set_listen_option(LogLevel logLevel, bool enable)
Definition: YarpLogger.cpp:760
yarp::yarpLogger::LoggerEngine::~LoggerEngine
~LoggerEngine()
Definition: YarpLogger.cpp:562
yarp::yarpLogger::LogEntryInfo::last_update
std::time_t last_update
Definition: YarpLogger.h:159
yarp::yarpLogger::LoggerEngine::set_log_list_max_size
void set_log_list_max_size(bool enabled, int new_size)
Definition: YarpLogger.cpp:1011
yarp::os::Value::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Value.cpp:359
yarp::yarpLogger::LogEntryInfo::logsize
unsigned int logsize
Definition: YarpLogger.h:160
yarp::yarpLogger::LOGSYSTEM_YARP
@ LOGSYSTEM_YARP
Definition: YarpLogger.h:114
yarp::yarpLogger::LoggerEngine::get_messages
void get_messages(std::list< MessageEntry > &messages)
Definition: YarpLogger.cpp:592
yarp::yarpLogger::LogLevel::toInt
int toInt()
Definition: YarpLogger.h:71
yarp::yarpLogger::LoggerEngine::get_messages_by_pid
void get_messages_by_pid(std::string pid, std::list< MessageEntry > &messages, bool from_beginning=false)
Definition: YarpLogger.cpp:716
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::yarpLogger::LoggerEngine::get_listen_option
bool get_listen_option(LogLevel logLevel)
Definition: YarpLogger.cpp:774
yarp::os::AbstractContactable::write
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition: AbstractContactable.cpp:149
yarp::yarpLogger::LoggerEngine::get_log_enable_by_port_complete
bool get_log_enable_by_port_complete(std::string port)
Definition: YarpLogger.cpp:1066
yarp::os::NetworkBase::exists
static bool exists(const std::string &port, bool quiet=true, bool checkVer=true)
Check for a port to be ready and responsive.
Definition: Network.cpp:749