Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Log.h"
- FILE *_file;
- tbb::spin_mutex _mutex;
- tbb::tick_count _t0;
- void eg::Log::init()
- {
- _t0 = tbb::tick_count::now();
- _file = fopen("Log.html", "w");
- fprintf(_file, "<html>\n");
- fprintf(_file, "<head>\n");
- fprintf(_file, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
- fprintf(_file, "<title>Game Engine Log</title>\n");
- fprintf(_file, "<style type=\"text/css\">\n");
- fprintf(_file, "body {\n");
- fprintf(_file, "background-color: #333333;\n");
- fprintf(_file, "font-family: arial;\n");
- fprintf(_file, "font-size: 16px;\n");
- fprintf(_file, "color: #e6e6e6;\n");
- fprintf(_file, "}\n");
- fprintf(_file, ".box {\n");
- fprintf(_file, "border-radius: 2px;\n");
- fprintf(_file, "padding: 4px;\n");
- fprintf(_file, "margin: 2px;\n");
- fprintf(_file, "margin: 48px 24px 48px 24px;\n");
- fprintf(_file, "background: #4d4d4d;\n");
- fprintf(_file, "box-shadow: 0px 0px 8px #000000;\n");
- fprintf(_file, "}\n");
- fprintf(_file, ".err {\n");
- fprintf(_file, "color: #ee1100;\n");
- fprintf(_file, "font-weight: bold\n");
- fprintf(_file, "}\n");
- fprintf(_file, ".wrn {\n");
- fprintf(_file, "color: #ffcc00;\n");
- fprintf(_file, "font-weight: bold\n");
- fprintf(_file, "}\n");
- fprintf(_file, ".inf {\n");
- fprintf(_file, "color: #e6e6e6;\n");
- fprintf(_file, "}\n");
- fprintf(_file, "</style>\n");
- fprintf(_file, "</head>\n\n");
- fprintf(_file, "<body>\n");
- fprintf(_file, "<div class=\"box\">\n");
- fprintf(_file, "<table>\n");
- }
- void eg::Log::shutdown()
- {
- fprintf(_file, "</table>\n");
- fprintf(_file, "</div>\n");
- fprintf(_file, "</body>\n");
- fprintf(_file, "</html>");
- fclose(_file);
- }
- void eg::Log::writeInformation(const char *text, ...)
- {
- tbb::spin_mutex::scoped_lock _lock(_mutex);
- va_list args;
- va_start(args, text);
- fprintf(_file, "<tr>\n");
- fprintf(_file, "<td width=\"100\">");
- fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
- fprintf(_file, "</td>\n");
- fprintf(_file, "<td class=\"inf\">\n");
- vfprintf(_file, text, args);
- fprintf(_file, "\n</td>\n");
- fprintf(_file, "</tr>\n");
- va_end(args);
- }
- void eg::Log::writeWarning(const char *text, ...)
- {
- tbb::spin_mutex::scoped_lock _lock(_mutex);
- va_list args;
- va_start(args, text);
- fprintf(_file, "<tr>\n");
- fprintf(_file, "<td width=\"100\">");
- fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
- fprintf(_file, "</td>\n");
- fprintf(_file, "<td class=\"wrn\">\n");
- vfprintf(_file, text, args);
- fprintf(_file, "\n</td>\n");
- fprintf(_file, "</tr>\n");
- va_end(args);
- }
- void eg::Log::writeError(const char *text, ...)
- {
- tbb::spin_mutex::scoped_lock _lock(_mutex);
- va_list args;
- va_start(args, text);
- fprintf(_file, "<tr>\n");
- fprintf(_file, "<td width=\"100\">");
- fprintf(_file, "%.3f", (tbb::tick_count::now() - _t0).seconds());
- fprintf(_file, "</td>\n");
- fprintf(_file, "<td class=\"err\">\n");
- vfprintf(_file, text, args);
- fprintf(_file, "\n</td>\n");
- fprintf(_file, "</tr>\n");
- va_end(args);
- }
Add Comment
Please, Sign In to add comment