This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 1/4] Add Log adaptors for printf-style output
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- Date: Thu, 5 Mar 2015 13:44:34 +0000
- Subject: [PATCH setup 1/4] Add Log adaptors for printf-style output
- Authentication-results: sourceware.org; auth=none
- References: <1425563077-1328-1-git-send-email-jon dot turney at dronecode dot org dot uk>
---
ChangeLog | 5 +++++
LogSingleton.cc | 28 ++++++++++++++++++++++++++++
LogSingleton.h | 5 +++++
3 files changed, 38 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 551cc94..0822701 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-04 Jon TURNEY <jon.turney@dronecode.org.uk>
+
+ * LogSingleton.cc (LogBabblePrintf, LogPlainPrintf): Add.
+ * LogSingleton.h: Ditto.
+
2015-03-02 Jon TURNEY <jon.turney@dronecode.org.uk>
* LogFile.cc (endEntry): Remove msg().
diff --git a/LogSingleton.cc b/LogSingleton.cc
index 387e6fe..a103a20 100644
--- a/LogSingleton.cc
+++ b/LogSingleton.cc
@@ -15,6 +15,7 @@
#include "LogSingleton.h"
#include <stdexcept>
+#include <stdarg.h>
using namespace std;
@@ -76,3 +77,30 @@ private:
static LogSingleton *theInstance;
};
#endif
+
+// Log adapators for printf-style output
+void
+LogBabblePrintf(const char *fmt, ...)
+{
+ int len;
+ char buf[2000];
+ va_list args;
+ va_start (args, fmt);
+ len = vsnprintf (buf, 2000, fmt, args);
+ if ((len > 0) && (buf[len-1] == '\n'))
+ buf[len-1] = 0;
+ Log (LOG_BABBLE) << buf << endLog;
+}
+
+void
+LogPlainPrintf(const char *fmt, ...)
+{
+ int len;
+ char buf[2000];
+ va_list args;
+ va_start (args, fmt);
+ len = vsnprintf (buf, 2000, fmt, args);
+ if ((len > 0) && (buf[len-1] == '\n'))
+ buf[len-1] = 0;
+ Log (LOG_PLAIN) << buf << endLog;
+}
diff --git a/LogSingleton.h b/LogSingleton.h
index 2c7a7c5..2fd1e36 100644
--- a/LogSingleton.h
+++ b/LogSingleton.h
@@ -57,4 +57,9 @@ extern std::ostream& endLog(std::ostream& outs);
//extern ostream& endLog(ostream& outs);
#define Log(X) (LogSingleton::GetInstance ()(X))
+
+// Log adapators for printf-style output
+void LogBabblePrintf(const char *fmt, ...);
+void LogPlainPrintf(const char *fmt, ...);
+
#endif /* SETUP_LOGSINGLETON_H */
--
2.1.4