Index: trunk/ippToPsps/src/FitsGenerator.c
===================================================================
--- trunk/ippToPsps/src/FitsGenerator.c	(revision 31030)
+++ trunk/ippToPsps/src/FitsGenerator.c	(revision 31033)
@@ -29,5 +29,6 @@
     }
 
-    if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name);
+    if (!column) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+            "Could not find column '%s' in table '%s'\n", name, table->name);
 
     return column;
@@ -49,5 +50,6 @@
     }
 
-    if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name);
+    if (!table) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+            "Could not find table '%s'\n", name);
 
     return table;
@@ -217,5 +219,6 @@
 
     xmlDoc* doc = xmlReadFile(path, NULL, 0);
-    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path);
+    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+            "Unable to open XML file at %s\n", path);
     return doc;
 }
@@ -253,5 +256,6 @@
     if(!tableNode) {
 
-        this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name);
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Could not find table: %s\n", table->name);
         return false;
     }
@@ -320,5 +324,6 @@
 
             }
-            if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n", 
+            if (status) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                    "Unable to write value of %s to column %s in table %s\n", 
                     tempStr, table->columns[i].pspsName, table->name);
         }
@@ -391,10 +396,13 @@
     if (columnNum < 1) {
 
-        this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName);
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Found no columns for table '%s'\n", tableName);
         ret = false;
     }
 
     if (columnNum != table->numOfColumns)
-        this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum);
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Mismatch between number of columns expected (%d) and those found (%d)\n", 
+                table->numOfColumns, columnNum);
 
     return ret;
@@ -424,5 +432,6 @@
     if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) {
 
-        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n");
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Root node of XML is not 'tableDescriptions', as it should be\n");
         return false;
     }
@@ -452,5 +461,7 @@
 
     if (tableNum != this->numOfTables)
-        this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum);
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Mismatch between number of tables expected (%d) and those found (%d)\n", 
+                this->numOfTables, tableNum);
 
     closeXmlFile(doc);
@@ -515,6 +526,59 @@
     bool ret = true;
 
+    char path[1000];
+    sprintf(path, "%s/map.xml", this->configsPath);
+
+    struct stat sts;
+    if ((stat(path, &sts)) == -1) {
+        this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 
+                "No map file found at '%s'\n", path);
+        return false;
+    }
+
+    xmlDoc* doc = openXmlFile(this, path);
+
+    if (doc == NULL) {
+        
+        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator",  
+                "Could not create XML document from '%s'\n", path);
+        return false;
+    }
+
+    this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 
+            "Using map file at '%s'\n", path);
+    xmlNode* rootElement = xmlDocGetRootElement(doc);
+
+    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
+        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator",  
+                "Root node of XML is not 'tabledata', as it should be\n");
+        return false;
+    }
+
+    xmlNode* node = NULL;
+
+    // loop round all available tables
+    for (node = rootElement->children; node; node = node->next) {
+        if (node->type == XML_ELEMENT_NODE) {
+
+            if (strcmp((const char*)node->name, "table")==0) {
+
+                if (!loadTableMappings(this, node)) ret = false;
+            }
+        }
+    }
+
+    closeXmlFile(doc);
+
+    return ret;
+}
+
+/**
+  Populate the provided table with data from XML
+  */
+static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
+
+    bool ret = true;
     psString path = NULL;
-    psStringAppend(&path, "%s/map.xml", this->configsPath);
+    psStringAppend(&path, "%s/data.xml", this->configsPath);
 
     xmlDoc* doc = openXmlFile(this, path);
@@ -529,47 +593,6 @@
 
     if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
-        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
-        return false;
-    }
-
-    xmlNode* node = NULL;
-
-    // loop round all available tables
-    for (node = rootElement->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "table")==0) {
-
-                if (!loadTableMappings(this, node)) ret = false;
-            }
-        }
-    }
-
-    closeXmlFile(doc);
-
-    return ret;
-}
-
-/**
-  Populate the provided table with data from XML
-  */
-static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
-
-    bool ret = true;
-    psString path = NULL;
-    psStringAppend(&path, "%s/data.xml", this->configsPath);
-
-    xmlDoc* doc = openXmlFile(this, path);
-
-    if (doc == NULL) {
-        psFree(path);
-        return false;
-    }
-    psFree(path);
-
-    xmlNode* rootElement = xmlDocGetRootElement(doc);
-
-    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
-        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
+        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
+                "Root node of XML is not 'tabledata', as it should be\n");
         return false;
     }
@@ -679,5 +702,5 @@
 
                 default:
-                    this->logger->print(this->logger, MSG_ERROR, "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
+                    this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
                             table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName);
                     break;
