Skip site navigation (1) Skip section navigation (2)

SVN Commit by dpage: r4192 - in trunk/pgadmin3/xtra/pgagent: . include

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by dpage: r4192 - in trunk/pgadmin3/xtra/pgagent: . include
Date: 2005-05-17 14:53:26
Message-ID: 200505171453.j4HErQba011596@developer.pgadmin.org (view raw or flat)
Thread:
Lists: pgadmin-hackers
Author: dpage
Date: 2005-05-17 15:53:26 +0100 (Tue, 17 May 2005)
New Revision: 4192

Modified:
   trunk/pgadmin3/xtra/pgagent/connection.cpp
   trunk/pgadmin3/xtra/pgagent/include/pgAgent.h
   trunk/pgadmin3/xtra/pgagent/job.cpp
   trunk/pgadmin3/xtra/pgagent/misc.cpp
   trunk/pgadmin3/xtra/pgagent/pgAgent.cpp
   trunk/pgadmin3/xtra/pgagent/unix.cpp
   trunk/pgadmin3/xtra/pgagent/win32.cpp
Log:
Add configurable message verbosity

Modified: trunk/pgadmin3/xtra/pgagent/connection.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/connection.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/connection.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -223,6 +223,9 @@
         else if (rc != PGRES_COMMAND_OK)
         {
             conn->lastError = PQerrorMessage(conn->conn);
+            char tmp[512];
+            snprintf(tmp, 511, "Query error: %s", conn->lastError.c_str());
+            LogMessage(tmp, LOG_WARNING);
             PQclear(result);
             result=0;
         }

Modified: trunk/pgadmin3/xtra/pgagent/include/pgAgent.h
===================================================================
--- trunk/pgadmin3/xtra/pgagent/include/pgAgent.h	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/include/pgAgent.h	2005-05-17 14:53:26 UTC (rev 4192)
@@ -24,22 +24,26 @@
 #include "connection.h"
 #include "job.h"
 
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
 extern long longWait;
 extern long shortWait;
+extern long minLogLevel;
 extern string connectString;
 extern string serviceDBname;
 
-// to be implemented platform dependent
-void CheckForInterrupt();
-
 // Log levels
 enum
 {
-	LOG_DEBUG = 1,
+	LOG_ERROR = 0,
 	LOG_WARNING,
-	LOG_ERROR
+	LOG_DEBUG
 };
 
+// Prototypes
+void CheckForInterrupt();
 void LogMessage(char *msg, int level);
 void MainLoop();
 

Modified: trunk/pgadmin3/xtra/pgagent/job.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/job.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/job.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -115,7 +115,12 @@
             {
                 conn=DBconn::Get(steps->GetString("jstdbname"));
                 if (conn)
+                {
+                    char tmp[512];
+                    snprintf(tmp, 511, "Executing job on '%s': %s\n", steps->GetString("jstdbname").c_str(), steps->GetString("jstcode").c_str());
+                    LogMessage(tmp, LOG_DEBUG);
                     rc=conn->ExecuteVoid(steps->GetString("jstcode"));
+                }
                 else
                     rc=-1;
 

Modified: trunk/pgadmin3/xtra/pgagent/misc.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/misc.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/misc.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -71,6 +71,13 @@
                         connPoolCount = val;
                     break;
                 }
+                case 'l':
+                {
+                    int val = atoi(getArg(argc, argv).c_str());
+                    if (val >= 0 && val <= 2)
+                        minLogLevel = val;
+                    break;
+                }
             }
         }
         else

Modified: trunk/pgadmin3/xtra/pgagent/pgAgent.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/pgAgent.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/pgAgent.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -21,10 +21,10 @@
 string serviceDBname;
 long longWait=30;
 long shortWait=10;
+long minLogLevel=LOG_ERROR;
 
 
 
-
 int MainRestartLoop(DBconn *serviceConn)
 {
     // clean up old jobs

Modified: trunk/pgadmin3/xtra/pgagent/unix.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/unix.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/unix.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -26,6 +26,7 @@
         "-t <poll time interval in seconds (default 10)>\n"
         "-r <retry period after connection abort in seconds (>=10, default 30)>\n"
         "-c <connection pool size (>=5, default 5)>\n"
+        "-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>\n"
         );
 }
 
@@ -34,10 +35,12 @@
     switch (level)
     {
         case LOG_DEBUG:
-            fprintf(stderr, "DEBUG: %s\n", msg);
+            if (minLogLevel >= LOG_DEBUG)
+                fprintf(stderr, "DEBUG: %s\n", msg);
             break;
         case LOG_WARNING:
-            fprintf(stderr, "WARNING: %s\n", msg);
+            if (minLogLevel >= LOG_WARNING)
+                fprintf(stderr, "WARNING: %s\n", msg);
             break;
         case LOG_ERROR:
             fprintf(stderr, "ERROR: %s\n", msg);

Modified: trunk/pgadmin3/xtra/pgagent/win32.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/win32.cpp	2005-05-17 14:13:14 UTC (rev 4191)
+++ trunk/pgadmin3/xtra/pgagent/win32.cpp	2005-05-17 14:53:26 UTC (rev 4192)
@@ -58,10 +58,12 @@
         switch (level)
         {
             case LOG_DEBUG:
-                fprintf(stderr, "DEBUG: %s\n", msg);
+                if (minLogLevel >= LOG_DEBUG)
+                    fprintf(stderr, "DEBUG: %s\n", msg);
                 break;
             case LOG_WARNING:
-                fprintf(stderr, "WARNING: %s\n", msg);
+                if (minLogLevel >= LOG_WARNING)
+                    fprintf(stderr, "WARNING: %s\n", msg);
                 break;
             case LOG_ERROR:
                 fprintf(stderr, "ERROR: %s\n", msg);
@@ -74,10 +76,12 @@
         switch (level)
         {
             case LOG_DEBUG:
-                fprintf(stderr, "DEBUG: %s\n", msg);
+                if (minLogLevel >= LOG_DEBUG)
+                    fprintf(stderr, "DEBUG: %s\n", msg);
                 break;
             case LOG_WARNING:
-                fprintf(stderr, "WARNING: %s\n", msg);
+                if (minLogLevel >= LOG_WARNING)
+                    fprintf(stderr, "WARNING: %s\n", msg);
                 break;
             case LOG_ERROR:
                 fprintf(stderr, "ERROR: %s\n", msg);
@@ -287,6 +291,7 @@
         "-t <poll time interval in seconds (default 10)>\n"
         "-r <retry period after connection abort in seconds (>=10, default 30)>\n"
         "-c <connection pool size (>=5, default 5)>\n"
+        "-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>\n"
         );
 }
 
@@ -306,7 +311,7 @@
     if (!conn->IsValid())
     {
         char tmp[255];
-        _snprintf(tmp, 254, "Connection not valid: %s", conn->GetLastError().c_str());
+        snprintf(tmp, 254, "Connection not valid: %s", conn->GetLastError().c_str());
         LogMessage(tmp, LOG_ERROR);
     }
 


pgadmin-hackers by date

Next:From: svnDate: 2005-05-17 15:27:06
Subject: SVN Commit by dpage: r4193 - in trunk/pgadmin3/xtra/pgagent: . include
Previous:From: svnDate: 2005-05-17 14:13:15
Subject: SVN Commit by dpage: r4191 - trunk/pgadmin3/xtra/pgagent

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group