feature/imgui-sdl
points-test
Last change
on this file since 155a7cf was 155a7cf, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago |
Replace printf with cout and cerr in new-game.cpp and logger.cpp
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[22b2c37] | 1 | #include "logger.h"
|
---|
| 2 |
|
---|
| 3 | #include <cstdio>
|
---|
| 4 | #include <ctime>
|
---|
| 5 | #include <cstdarg>
|
---|
[155a7cf] | 6 | #include <iostream>
|
---|
| 7 |
|
---|
| 8 | using namespace std;
|
---|
[22b2c37] | 9 |
|
---|
| 10 | bool restart_gl_log() {
|
---|
| 11 | FILE* file = fopen(GL_LOG_FILE, "w");
|
---|
| 12 | if (!file) {
|
---|
[155a7cf] | 13 | cerr << "ERROR: could not open GL_LOG_FILE log file " << GL_LOG_FILE << " for writing" << endl;
|
---|
[22b2c37] | 14 | return false;
|
---|
| 15 | }
|
---|
| 16 | time_t now = time(NULL);
|
---|
| 17 | char* date = ctime(&now);
|
---|
| 18 | fprintf(file, "GL_LOG_FILE log. local time %s\n", date);
|
---|
| 19 | fclose(file);
|
---|
| 20 | return true;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | bool gl_log(const char* message, ...) {
|
---|
| 24 | va_list argptr;
|
---|
| 25 | FILE* file = fopen(GL_LOG_FILE, "a");
|
---|
| 26 | if (!file) {
|
---|
[155a7cf] | 27 | cerr << "ERROR: could not open GL_LOG_FILE log file " << GL_LOG_FILE << " for appending" << endl;
|
---|
[22b2c37] | 28 | return false;
|
---|
| 29 | }
|
---|
| 30 | va_start(argptr, message);
|
---|
| 31 | vfprintf(file, message, argptr);
|
---|
| 32 | va_end(argptr);
|
---|
| 33 | fprintf(file, "\n");
|
---|
| 34 | fclose(file);
|
---|
| 35 | return true;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | bool gl_log_err(const char* message, ...) {
|
---|
| 39 | va_list argptr;
|
---|
| 40 | FILE* file = fopen(GL_LOG_FILE, "a");
|
---|
| 41 | if (!file) {
|
---|
[155a7cf] | 42 | cerr << "ERROR: could not open GL_LOG_FILE log file " << GL_LOG_FILE << " for appending" << endl;
|
---|
[22b2c37] | 43 | return false;
|
---|
| 44 | }
|
---|
| 45 | va_start(argptr, message);
|
---|
| 46 | vfprintf(file, message, argptr);
|
---|
| 47 | va_end(argptr);
|
---|
| 48 | fprintf(file, "\n");
|
---|
| 49 | va_start(argptr, message);
|
---|
| 50 | vfprintf(stderr, message, argptr);
|
---|
| 51 | va_end(argptr);
|
---|
| 52 | fprintf(stderr, "\n");
|
---|
| 53 | fclose(file);
|
---|
| 54 | return true;
|
---|
| 55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.