diff --git a/mongoose.c b/mongoose.c
index d1bce24b1e114df5121d93e9d8647d42e06c6fef..5397ec72eeae1889143d4936437fec8739cc5d6d 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -372,6 +372,11 @@ void cs_log_printf(const char *fmt, ...) {
   fputc('\n', cs_log_file);
   fflush(cs_log_file);
 }
+
+void cs_log_set_file(FILE *file) {
+  cs_log_file = file;
+}
+
 #endif /* !CS_DISABLE_STDIO */
 
 void cs_log_set_level(enum cs_log_level level) {
@@ -380,10 +385,6 @@ void cs_log_set_level(enum cs_log_level level) {
   cs_log_ts = cs_time();
 #endif
 }
-
-void cs_log_set_file(FILE *file) {
-  cs_log_file = file;
-}
 #ifdef MG_MODULE_LINES
 #line 1 "./src/../../common/cs_dirent.c"
 #endif
diff --git a/mongoose.h b/mongoose.h
index c6c09cf426945270c6e64af2b3f1c4032ed17b47..4644fcbcb85df8f1b037a2da7234d9da2f017136 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -32,6 +32,8 @@
 #endif
 #if defined(MG_DISABLE_STDIO) && !defined(CS_DISABLE_STDIO)
 #define CS_DISABLE_STDIO
+#elif defined(CS_DISABLE_STDIO) && !defined(MG_DISABLE_STDIO)
+#define MG_DISABLE_STDIO
 #endif
 
 /* All of the below features depend on filesystem access, disable them. */