diff --git a/CMakeLists.txt b/CMakeLists.txt index 93cb672..6c74647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ macro(tri_option name desc default) set_property(CACHE "${name}" PROPERTY STRINGS AUTO ON OFF) endmacro() +option(CHIAKI_ENABLE_FILE_LOG "Enable debug file log" OFF) option(CHIAKI_ENABLE_TESTS "Enable tests for Chiaki" OFF) option(CHIAKI_ENABLE_CLI "Enable CLI for Chiaki" OFF) option(CHIAKI_ENABLE_ANDROID "Enable Android (Use only as part of the Gradle Project)" OFF) diff --git a/lib/src/log.c b/lib/src/log.c index f7e91fe..29c0ec0 100644 --- a/lib/src/log.c +++ b/lib/src/log.c @@ -73,7 +73,7 @@ CHIAKI_EXPORT void chiaki_log(ChiakiLog *log, ChiakiLogLevel level, const char * va_start(args, fmt); int written = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - +#ifdef CHIAKI_ENABLE_FILE_LOG FILE *logFile = fopen("chiaki.log", "a"); if (logFile != NULL) { fprintf(logFile, "%s\n", msg); @@ -81,6 +81,7 @@ CHIAKI_EXPORT void chiaki_log(ChiakiLog *log, ChiakiLogLevel level, const char * } else { fprintf(stderr, "Unable to open log file\n"); } +#endif if(written < 0) return; @@ -94,7 +95,7 @@ CHIAKI_EXPORT void chiaki_log(ChiakiLog *log, ChiakiLogLevel level, const char * va_start(args, fmt); written = vsnprintf(msg, written + 1, fmt, args); va_end(args); - +#ifdef CHIAKI_ENABLE_FILE_LOG FILE *logFile = fopen("chiaki.log", "a"); if (logFile != NULL) { fprintf(logFile, "%s\n", msg); @@ -102,7 +103,7 @@ CHIAKI_EXPORT void chiaki_log(ChiakiLog *log, ChiakiLogLevel level, const char * } else { fprintf(stderr, "Unable to open log file\n"); } - +#endif if(written < 0) { free(msg);