diff --git a/src/message.h b/src/message.h
index 28af017c2c95a33c4d862e8d7e3f02700d5adc89..e0cd6f46fc589c03e0936eade6458daa923aeac4 100644
--- a/src/message.h
+++ b/src/message.h
@@ -11,8 +11,13 @@
 
 #ifdef L4N_DEBUG
 #define COUT_DEBUG(inp) assert(std::cerr << std::flush << "DEBUG: " << inp << std::flush)
+
+#define WRITE_TO_OFS_DEBUG(ofs, msg) { if(ofs && ofs->is_open())\
+                                           *ofs << "DEBUG: " << msg;\
+                                     }
 #else
 #define COUT_DEBUG(inp)
+#define WRITE_TO_OFS_DEBUG(ofs, msg)
 #endif // L4N_DEBUG
 
 #endif //PROJECT_MESSAGE_H