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

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

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by dpage: r4193 - in trunk/pgadmin3/xtra/pgagent: . include
Date: 2005-05-17 15:27:06
Message-ID: 200505171527.j4HFR6ud012146@developer.pgadmin.org (view raw or flat)
Thread:
Lists: pgadmin-hackers
Author: dpage
Date: 2005-05-17 16:27:06 +0100 (Tue, 17 May 2005)
New Revision: 4193

Modified:
   trunk/pgadmin3/xtra/pgagent/connection.cpp
   trunk/pgadmin3/xtra/pgagent/include/pgAgent.h
   trunk/pgadmin3/xtra/pgagent/job.cpp
   trunk/pgadmin3/xtra/pgagent/unix.cpp
   trunk/pgadmin3/xtra/pgagent/win32.cpp
Log:
Further logging improvements

Modified: trunk/pgadmin3/xtra/pgagent/connection.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/connection.cpp	2005-05-17 14:53:26 UTC (rev 4192)
+++ trunk/pgadmin3/xtra/pgagent/connection.cpp	2005-05-17 15:27:06 UTC (rev 4193)
@@ -223,9 +223,7 @@
         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);
+            LogMessage("Query error: " + conn->lastError, 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:53:26 UTC (rev 4192)
+++ trunk/pgadmin3/xtra/pgagent/include/pgAgent.h	2005-05-17 15:27:06 UTC (rev 4193)
@@ -24,10 +24,6 @@
 #include "connection.h"
 #include "job.h"
 
-#ifdef WIN32
-#define snprintf _snprintf
-#endif
-
 extern long longWait;
 extern long shortWait;
 extern long minLogLevel;
@@ -44,7 +40,7 @@
 
 // Prototypes
 void CheckForInterrupt();
-void LogMessage(char *msg, int level);
+void LogMessage(string msg, int level);
 void MainLoop();
 
 #endif // PGAGENT_H

Modified: trunk/pgadmin3/xtra/pgagent/job.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/job.cpp	2005-05-17 14:53:26 UTC (rev 4192)
+++ trunk/pgadmin3/xtra/pgagent/job.cpp	2005-05-17 15:27:06 UTC (rev 4193)
@@ -70,7 +70,7 @@
         "  FROM pgagent.pga_jobstep "
         " WHERE jstenabled "
         "   AND jstjobid=" + jobid +
-        " ORDER BY jstid, jstdbname");
+        " ORDER BY jstname, jstid");
 
     if (!steps)
     {
@@ -116,9 +116,7 @@
                 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);
+                    LogMessage("Executing step " + steps->GetString("jstid") + " on database " + steps->GetString("jstdbname"), LOG_DEBUG);
                     rc=conn->ExecuteVoid(steps->GetString("jstcode"));
                 }
                 else

Modified: trunk/pgadmin3/xtra/pgagent/unix.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/unix.cpp	2005-05-17 14:53:26 UTC (rev 4192)
+++ trunk/pgadmin3/xtra/pgagent/unix.cpp	2005-05-17 15:27:06 UTC (rev 4193)
@@ -30,20 +30,20 @@
         );
 }
 
-void LogMessage(char *msg, int level)
+void LogMessage(string msg, int level)
 {
     switch (level)
     {
         case LOG_DEBUG:
             if (minLogLevel >= LOG_DEBUG)
-                fprintf(stderr, "DEBUG: %s\n", msg);
+                fprintf(stderr, "DEBUG: %s\n", msg.c_str());
             break;
         case LOG_WARNING:
             if (minLogLevel >= LOG_WARNING)
-                fprintf(stderr, "WARNING: %s\n", msg);
+                fprintf(stderr, "WARNING: %s\n", msg.c_str());
             break;
         case LOG_ERROR:
-            fprintf(stderr, "ERROR: %s\n", msg);
+            fprintf(stderr, "ERROR: %s\n", msg.c_str());
             exit(1);
             break;
     }
@@ -89,11 +89,7 @@
 
     DBconn *conn=DBconn::InitConnection(connectString);
     if (!conn->IsValid())
-    {
-        char tmp[255];
-        snprintf(tmp, 254, "Connection not valid: %s", conn->GetLastError().c_str());
-        LogMessage(tmp, LOG_ERROR);
-    }
+        LogMessage("Invalid connection: " + conn->GetLastError(), LOG_ERROR);
 
     serviceDBname = conn->GetDBname();
 

Modified: trunk/pgadmin3/xtra/pgagent/win32.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/win32.cpp	2005-05-17 14:53:26 UTC (rev 4192)
+++ trunk/pgadmin3/xtra/pgagent/win32.cpp	2005-05-17 15:27:06 UTC (rev 4193)
@@ -50,7 +50,7 @@
     serviceIsRunning = true;
 }
 
-void LogMessage(char *msg, int level)
+void LogMessage(string msg, int level)
 {
     if (eventHandle)
     {
@@ -59,14 +59,14 @@
         {
             case LOG_DEBUG:
                 if (minLogLevel >= LOG_DEBUG)
-                    fprintf(stderr, "DEBUG: %s\n", msg);
+                    fprintf(stderr, "DEBUG: %s\n", msg.c_str());
                 break;
             case LOG_WARNING:
                 if (minLogLevel >= LOG_WARNING)
-                    fprintf(stderr, "WARNING: %s\n", msg);
+                    fprintf(stderr, "WARNING: %s\n", msg.c_str());
                 break;
             case LOG_ERROR:
-                fprintf(stderr, "ERROR: %s\n", msg);
+                fprintf(stderr, "ERROR: %s\n", msg.c_str());
                 exit(1);
                 break;
         }
@@ -77,14 +77,14 @@
         {
             case LOG_DEBUG:
                 if (minLogLevel >= LOG_DEBUG)
-                    fprintf(stderr, "DEBUG: %s\n", msg);
+                    fprintf(stderr, "DEBUG: %s\n", msg.c_str());
                 break;
             case LOG_WARNING:
                 if (minLogLevel >= LOG_WARNING)
-                    fprintf(stderr, "WARNING: %s\n", msg);
+                    fprintf(stderr, "WARNING: %s\n", msg.c_str());
                 break;
             case LOG_ERROR:
-                fprintf(stderr, "ERROR: %s\n", msg);
+                fprintf(stderr, "ERROR: %s\n", msg.c_str());
                 exit(1);
                 break;
         }
@@ -309,11 +309,7 @@
 
     DBconn *conn=DBconn::InitConnection(connectString);
     if (!conn->IsValid())
-    {
-        char tmp[255];
-        snprintf(tmp, 254, "Connection not valid: %s", conn->GetLastError().c_str());
-        LogMessage(tmp, LOG_ERROR);
-    }
+        LogMessage("Invalid connection: " + conn->GetLastError(), LOG_ERROR);
 
     serviceDBname = conn->GetDBname();
 }


pgadmin-hackers by date

Next:From: svnDate: 2005-05-17 15:47:29
Subject: SVN Commit by dpage: r4194 - in trunk/pgadmin3/xtra/pgagent: . include
Previous:From: svnDate: 2005-05-17 14:53:26
Subject: SVN Commit by dpage: r4192 - in trunk/pgadmin3/xtra/pgagent: . include

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