Guest User

Untitled

a guest
May 24th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. #include "Log.h"
  2.  
  3. FILE *_file;
  4. tbb::spin_mutex _mutex;
  5. tbb::tick_count _t0;
  6.  
  7. void eg::Log::init()
  8. {
  9. _t0 = tbb::tick_count::now();
  10.  
  11. _file = fopen("Log.html", "w");
  12.  
  13. fprintf(_file, "<html>\n");
  14. fprintf(_file, "<head>\n");
  15. fprintf(_file, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  16. fprintf(_file, "<title>Game Engine Log</title>\n");
  17. fprintf(_file, "<style type=\"text/css\">\n");
  18.  
  19. fprintf(_file, "body {\n");
  20. fprintf(_file, "background-color: #333333;\n");
  21. fprintf(_file, "font-family: arial;\n");
  22. fprintf(_file, "font-size: 16px;\n");
  23. fprintf(_file, "color: #e6e6e6;\n");
  24. fprintf(_file, "}\n");
  25.  
  26. fprintf(_file, ".box {\n");
  27. fprintf(_file, "border-radius: 2px;\n");
  28. fprintf(_file, "padding: 4px;\n");
  29. fprintf(_file, "margin: 2px;\n");
  30. fprintf(_file, "margin: 48px 24px 48px 24px;\n");
  31. fprintf(_file, "background: #4d4d4d;\n");
  32. fprintf(_file, "box-shadow: 0px 0px 8px #000000;\n");
  33. fprintf(_file, "}\n");
  34.  
  35. fprintf(_file, ".err {\n");
  36. fprintf(_file, "color: #ee1100;\n");
  37. fprintf(_file, "font-weight: bold\n");
  38. fprintf(_file, "}\n");
  39.  
  40. fprintf(_file, ".wrn {\n");
  41. fprintf(_file, "color: #ffcc00;\n");
  42. fprintf(_file, "font-weight: bold\n");
  43. fprintf(_file, "}\n");
  44.  
  45. fprintf(_file, ".inf {\n");
  46. fprintf(_file, "color: #e6e6e6;\n");
  47. fprintf(_file, "}\n");
  48.  
  49. fprintf(_file, "</style>\n");
  50. fprintf(_file, "</head>\n\n");
  51.  
  52. fprintf(_file, "<body>\n");
  53. fprintf(_file, "<div class=\"box\">\n");
  54. fprintf(_file, "<table>\n");
  55. }
  56.  
  57. void eg::Log::shutdown()
  58. {
  59. fprintf(_file, "</table>\n");
  60. fprintf(_file, "</div>\n");
  61. fprintf(_file, "</body>\n");
  62. fprintf(_file, "</html>");
  63.  
  64. fclose(_file);
  65. }
  66.  
  67. void eg::Log::writeInformation(const char *text, ...)
  68. {
  69. tbb::spin_mutex::scoped_lock _lock(_mutex);
  70.  
  71. va_list args;
  72. va_start(args, text);
  73.  
  74. fprintf(_file, "<tr>\n");
  75. fprintf(_file, "<td width=\"100\">");
  76. fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
  77. fprintf(_file, "</td>\n");
  78. fprintf(_file, "<td class=\"inf\">\n");
  79.  
  80. vfprintf(_file, text, args);
  81. fprintf(_file, "\n</td>\n");
  82. fprintf(_file, "</tr>\n");
  83.  
  84. va_end(args);
  85. }
  86.  
  87. void eg::Log::writeWarning(const char *text, ...)
  88. {
  89. tbb::spin_mutex::scoped_lock _lock(_mutex);
  90.  
  91. va_list args;
  92. va_start(args, text);
  93.  
  94. fprintf(_file, "<tr>\n");
  95. fprintf(_file, "<td width=\"100\">");
  96. fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
  97. fprintf(_file, "</td>\n");
  98. fprintf(_file, "<td class=\"wrn\">\n");
  99.  
  100. vfprintf(_file, text, args);
  101. fprintf(_file, "\n</td>\n");
  102. fprintf(_file, "</tr>\n");
  103.  
  104. va_end(args);
  105. }
  106.  
  107. void eg::Log::writeError(const char *text, ...)
  108. {
  109. tbb::spin_mutex::scoped_lock _lock(_mutex);
  110.  
  111. va_list args;
  112. va_start(args, text);
  113.  
  114. fprintf(_file, "<tr>\n");
  115. fprintf(_file, "<td width=\"100\">");
  116. fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
  117. fprintf(_file, "</td>\n");
  118. fprintf(_file, "<td class=\"err\">\n");
  119.  
  120. vfprintf(_file, text, args);
  121. fprintf(_file, "\n</td>\n");
  122. fprintf(_file, "</tr>\n");
  123.  
  124. va_end(args);
  125. }
Add Comment
Please, Sign In to add comment