Skip to content

Commit

Permalink
A enviromental variable, SQAOD_VERBOSE, is introduced.
Browse files Browse the repository at this point in the history
SQAOD will output logs when SQAOD_VERBOSE is defined an its value is not '0'.
  • Loading branch information
shinmorino committed Apr 30, 2018
1 parent cdadd63 commit f58070f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions sqaodc/common/defines.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define _CRT_SECURE_NO_WARNINGS /* disable warning on Windows since the usage of getenv() is safe here. */
#include <stdlib.h>
#include "defines.h"
#include "undef.h"

Expand Down Expand Up @@ -40,11 +42,23 @@ void sqaod::__throwError(const char *file, unsigned long line, const char *forma
throw std::runtime_error(buffer);
}


void sqaod::log(const char *format, ...) {
va_list va;
va_start(va, format);
vfprintf(stderr, format, va);
va_end(va);
fprintf(stderr, "\n");
static int verbose = -1;
if (verbose == -1) {
const char *env = getenv("SQAOD_VERBOSE");
if ((env != NULL) && (*env != '0'))
verbose = 1;
else
verbose = 0;
}

if (verbose) {
va_list va;
va_start(va, format);
vfprintf(stderr, format, va);
va_end(va);
fprintf(stderr, "\n");
}
}

0 comments on commit f58070f

Please sign in to comment.