]> www.vanbest.org Git - sasc-ng.git/commitdiff
add logging callback for sasc-ng
authoranisota <unknown>
Sun, 13 Jan 2008 20:13:31 +0000 (21:13 +0100)
committeranisota <unknown>
Sun, 13 Jan 2008 20:13:31 +0000 (21:13 +0100)
log.c
log.h

diff --git a/log.c b/log.c
index 170d4da1fc246960e3ea72b65ff285dc41a78b7b..290f7e8ddb4c6c25cb9a5b965809d486759593b8 100644 (file)
--- a/log.c
+++ b/log.c
 #define LMOD_SUP 32
 #define LMOD_CFG_VALID  0x80000000
 
-struct LogHeader {
-  int c;
-  char stamp[32];
-  char tag[64];
-  };
-
 struct LogConfig logcfg = {
   1,0,0,
   0,
@@ -64,6 +58,8 @@ static cMutex lastMutex;
 
 // -- cLogging -----------------------------------------------------------------
 
+void (*cLogging::LogPrint)(const struct LogHeader *lh, const char *txt)=cLogging::PrivateLogPrint;
+
 bool cLogging::AddModule(int m, const struct LogModule *lm)
 {
   if(m<LMOD_SUP) {
@@ -77,6 +73,11 @@ bool cLogging::AddModule(int m, const struct LogModule *lm)
   return true;
 }
 
+void cLogging::SetLogPrint(void (*lp)(const struct LogHeader *lh, const char *txt))
+{
+  LogPrint=lp;
+}
+
 const struct LogModule *cLogging::GetModule(int c)
 {
   int m=LMOD(c);
@@ -126,6 +127,11 @@ void cLogging::LogLine(const struct LogHeader *lh, const char *txt, bool doCrc)
       }
     }
 
+  LogPrint(lh,txt);
+}
+
+void cLogging::PrivateLogPrint(const struct LogHeader *lh, const char *txt)
+{
   if(logcfg.logFile) {
     logfileMutex.Lock();
     if(logfileReopen) {
diff --git a/log.h b/log.h
index 38fa86b644586e0c12be711e94c6e027a5bd44c1..fb1be1fba90ab2244d898c85886a110acd704785 100644 (file)
--- a/log.h
+++ b/log.h
@@ -80,16 +80,24 @@ struct LogModule {
   const char *Name, *OptName[LOPT_NUM];
   };
 
-struct LogHeader;
+struct LogHeader {
+  int c;
+  char stamp[32];
+  char tag[64];
+  };
 
 class cLogging {
 private:
+  static void (*LogPrint)(const struct LogHeader *lh, const char *txt);
+  //
+  static void PrivateLogPrint(const struct LogHeader *lh, const char *txt);
   static bool GetHeader(int c, struct LogHeader *lh);
   static void LogLine(const struct LogHeader *lh, const char *txt, bool doCrc=true);
   static const struct LogModule *GetModule(int c);
   static void UpgradeOptions(int m);
 public:
   static bool AddModule(int m, const struct LogModule *dm);
+  static void SetLogPrint(void (*lp)(const struct LogHeader *lh, const char *txt));
   //
   static void Printf(int c, const char *format, ...) __attribute__ ((format (printf,2,3)));
   static void Puts(int c, const char *txt);