Symulacja NAT na przedmiot Symulacje Komputerowe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.2 KiB

  1. /*
  2. * Log.cpp
  3. *
  4. * Created on: 16.01.2017
  5. * Author: piotrek
  6. */
  7. #include "Log.h"
  8. Log::Log()
  9. {
  10. this->color = WHITE;
  11. this->delimiter = "";
  12. this->lineNumber = 0;
  13. this->objectName = NULL;
  14. }
  15. LOG_COLOR Log::getColor() const
  16. {
  17. return color;
  18. }
  19. void Log::setColor(LOG_COLOR color)
  20. {
  21. this->color = color;
  22. }
  23. const string& Log::getDelimiter() const
  24. {
  25. return delimiter;
  26. }
  27. void Log::setDelimiter(const string& delimiter)
  28. {
  29. this->delimiter = delimiter;
  30. }
  31. int Log::getLineNumber() const
  32. {
  33. return lineNumber;
  34. }
  35. void Log::setLineNumber(int lineNumber)
  36. {
  37. this->lineNumber = lineNumber;
  38. }
  39. string* Log::getObjectName() const
  40. {
  41. return objectName;
  42. }
  43. void Log::setObjectName(string* objectName)
  44. {
  45. this->objectName = objectName;
  46. }
  47. void Log::print(string msg)
  48. {
  49. if (this->getObjectName() == NULL)
  50. return;
  51. move(this->getLineNumber(), 0);
  52. clrtoeol();
  53. if(has_colors())
  54. attron(COLOR_PAIR(this->getColor()));
  55. printw("%s:%s%s", this->getObjectName()->c_str(), this->getDelimiter().c_str(), msg.c_str());
  56. if(has_colors())
  57. attroff(COLOR_PAIR(this->getColor()));
  58. move(0, 0);
  59. }
  60. void Log::setLogParams(int lineNumber, LOG_COLOR color, string delimiter)
  61. {
  62. this->setLineNumber(lineNumber);
  63. this->setColor(color);
  64. this->setDelimiter(delimiter);
  65. }