[Kst] branches/work/kst/1.6/kst/src/extensions/js

Andrew Walker arwalker at sumusltd.com
Tue Oct 30 21:21:16 CET 2007


SVN commit 731135 by arwalker:

continue enhancing DebugLog object

 M  +137 -0    bind_debuglog.cpp  
 M  +52 -0     bind_debuglog.h  


--- branches/work/kst/1.6/kst/src/extensions/js/bind_debuglog.cpp #731134:731135
@@ -65,6 +65,14 @@
 static DebugLogProperties debugLogProperties[] = {
   { "length", 0L, &KstBindDebugLog::length },
   { "text", 0L, &KstBindDebugLog::text },
+  { "lengthNotices", 0L, &KstBindDebugLog::lengthNotices },
+  { "textNotices", 0L, &KstBindDebugLog::textNotices },
+  { "lengthWarnings", 0L, &KstBindDebugLog::lengthWarnings },
+  { "textWarnings", 0L, &KstBindDebugLog::textWarnings },
+  { "lengthErrors", 0L, &KstBindDebugLog::lengthErrors },
+  { "textErrors", 0L, &KstBindDebugLog::textErrors },
+  { "lengthDebugs", 0L, &KstBindDebugLog::lengthDebugs },
+  { "textDebugs", 0L, &KstBindDebugLog::textDebugs },
   { 0L, 0L, 0L }
 };
 
@@ -163,12 +171,14 @@
 
 KJS::Value KstBindDebugLog::length(KJS::ExecState *exec) const {
   Q_UNUSED(exec)
+
   return KJS::Number(KstDebug::self()->logLength());
 }
 
 
 KJS::Value KstBindDebugLog::text(KJS::ExecState *exec) const {
   Q_UNUSED(exec)
+
   QString log;
   QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
 
@@ -195,3 +205,130 @@
 
   return KJS::String(log);
 }
+
+
+KJS::Value KstBindDebugLog::lengthNotices(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+  int num = 0;
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Notice) {
+      num++;
+    }
+  }
+
+  return KJS::Number(num);
+}
+
+KJS::Value KstBindDebugLog::textNotices(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QString log;
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Notice) {
+      log += i18n("date logtext", "%1 %2\n").arg(KGlobal::locale()->formatDateTime((*i).date)).arg((*i).msg);
+    }
+  }
+
+  return KJS::String(log);
+}
+
+
+KJS::Value KstBindDebugLog::lengthWarnings(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+  int num = 0;
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Warning) {
+      num++;
+    }
+  }
+
+  return KJS::Number(num);
+}
+
+
+KJS::Value KstBindDebugLog::textWarnings(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QString log;
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Warning) {
+      log += i18n("date logtext", "%1 %2\n").arg(KGlobal::locale()->formatDateTime((*i).date)).arg((*i).msg);
+    }
+  }
+
+  return KJS::String(log);
+}
+
+
+KJS::Value KstBindDebugLog::lengthErrors(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+  int num = 0;
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Error) {
+      num++;
+    }
+  }
+
+  return KJS::Number(num);
+}
+
+
+KJS::Value KstBindDebugLog::textErrors(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QString log;
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Error) {
+      log += i18n("date logtext", "%1 %2\n").arg(KGlobal::locale()->formatDateTime((*i).date)).arg((*i).msg);
+    }
+  }
+
+  return KJS::String(log);
+}
+
+
+KJS::Value KstBindDebugLog::lengthDebugs(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+  int num = 0;
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Debug) {
+      num++;
+    }
+  }
+
+  return KJS::Number(num);
+}
+
+
+KJS::Value KstBindDebugLog::textDebugs(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+
+  QString log;
+  QValueList<KstDebug::LogMessage> msgs = KstDebug::self()->messages();
+
+  for (QValueList<KstDebug::LogMessage>::ConstIterator i = msgs.begin(); i != msgs.end(); ++i) {
+    if ((*i).level == KstDebug::Debug) {
+      log += i18n("date logtext", "%1 %2\n").arg(KGlobal::locale()->formatDateTime((*i).date)).arg((*i).msg);
+    }
+  }
+
+  return KJS::String(log);
+}
--- branches/work/kst/1.6/kst/src/extensions/js/bind_debuglog.h #731134:731135
@@ -59,6 +59,58 @@
     */
     KJS::Value text(KJS::ExecState *exec) const;
 
+    /* @property string lengthNotices
+       @readonly
+       @description The number of notices in the log.
+    */
+    KJS::Value lengthNotices(KJS::ExecState *exec) const;
+
+    /* @property string textNotices
+       @readonly
+       @description The text contents of the log notices as a single large string with
+                    carriage returns between entries.
+    */
+    KJS::Value textNotices(KJS::ExecState *exec) const;
+
+    /* @property string lengthWarnings
+       @readonly
+       @description The number of warnings in the log.
+    */
+    KJS::Value lengthWarnings(KJS::ExecState *exec) const;
+
+    /* @property string textWarnings
+       @readonly
+       @description The text contents of the log warnings as a single large string with
+                    carriage returns between entries.
+    */
+    KJS::Value textWarnings(KJS::ExecState *exec) const;
+
+    /* @property string lengthErrors
+       @readonly
+       @description The number of errors in the log.
+    */
+    KJS::Value lengthErrors(KJS::ExecState *exec) const;
+
+    /* @property string textErrors
+       @readonly
+       @description The text contents of the log errors as a single large string with
+                    carriage returns between entries.
+    */
+    KJS::Value textErrors(KJS::ExecState *exec) const;
+
+    /* @property string lengthDebugs
+       @readonly
+       @description The number of debug messages in the log.
+    */
+    KJS::Value lengthDebugs(KJS::ExecState *exec) const;
+
+    /* @property string textDebugs
+       @readonly
+       @description The text contents of the log debug messages as a single large string with
+                    carriage returns between entries.
+    */
+    KJS::Value textDebugs(KJS::ExecState *exec) const;
+
   protected:
     KstBindDebugLog(int id);
     void addBindings(KJS::ExecState *exec, KJS::Object& obj);


More information about the Kst mailing list