powerguru-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Powerguru-commit] [SCM] powerguru branch, master, updated. 68ff1919bf09


From: Rob Savoye
Subject: [Powerguru-commit] [SCM] powerguru branch, master, updated. 68ff1919bf090c4ccc48a79211c858dcc91d83a9
Date: Fri, 28 Dec 2018 22:34:15 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".

The branch, master has been updated
       via  68ff1919bf090c4ccc48a79211c858dcc91d83a9 (commit)
       via  146485a0d232a412e904c26e48aa287909e4e3f8 (commit)
      from  0c47e74d16350892beddfc93e4c0815831719e1c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=68ff1919bf090c4ccc48a79211c858dcc91d83a9


commit 68ff1919bf090c4ccc48a79211c858dcc91d83a9
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 28 20:34:00 2018 -0700

    Drop usage of custom LogFile to use boost::log

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index e7de490..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "OneWire"]
-       path = OneWire
-       url = https://github.com/PaulStoffregen/OneWire.git
diff --git a/README b/README
index d2edc6b..bc5fe65 100644
--- a/README
+++ b/README
@@ -1,23 +1,39 @@
-2005-05-27
-  Currently I'd ignore the src directory. This is the support code for the
-barely started Glade2 GUI. I postponed this to make powerguru have a
-separete backend and GUI, rather than the way I was doing it with TraceGUI.
+struct servent {
+     char  *s_name;       /* official service name */
+     char **s_aliases;    /* alias list */
+     int    s_port;       /* port number */
+     char  *s_proto;      /* protocol to use */
+}
 
-  Not much works but datalogging to a MySQL database someplace. I've got
-broadband, so I write my data to my server at work. I've just started the PHP
-pages to plot the data. These are in the web directory, but once again, barely
-started.
+The members of the servent structure are:
+     s_name The official name of the service.
+     s_aliases A NULL-terminated list of alternative names for the service.
+     s_port The port number for the service given in network byte order.
+     s_proto The name of the protocol to use with this service.
 
-  This originally started life as TraceGUI, but I got distracted rebuilding
-my entire houses's power system, GTK1 and Glade1 went to 2.0 releases that were
-incompatable enough with the previous versions to make upgrading slow. Then
-Trace became Xantrex, and I bought an Outback MX-60...
 
-  I got the idea to make a tiny backend so it would run on a 12VDC,
-Linux based motherboard like a Nexus, a Via, or a Soekris. This would do
-datalogging directly and support an SNMP connection to execute remote commands.
-This way I could have multiple front ends, a command line interface, a
-graphical one, and a web based one. Ideally I'd even like one that's written
-in QT or Java so I can run it on my Zaurus 6000-L.
+struct protoent {
+     char  *p_name;       /* official protocol name */
+     char **p_aliases;    /* alias list */
+     int    p_proto;      /* protocol number */
+}
 
-       - rob -
+       The members of the protoent structure are:
+       p_name The official name of the protocol.
+       p_aliases A NULL-terminated list of alternative names for the protocol.
+       p_proto The protocol number.
+
+The  addrinfo  structure  used  by getaddrinfo() contains the following fields:
+
+struct addrinfo {
+       int              ai_flags;
+       int              ai_family;
+       int              ai_socktype;
+       int              ai_protocol;
+       socklen_t        ai_addrlen;
+       struct sockaddr *ai_addr;
+       char            *ai_canonname;
+       struct addrinfo *ai_next;
+}
+
+getaddrinfo() is an excellent function that will return information on a 
particular host name (such as its IP address) and load up a struct sockaddr for 
you, taking care of the gritty details (like if it's IPv4 or IPv6.) It replaces 
the old functions gethostbyname() and getservbyname().T
\ No newline at end of file
diff --git a/client/Makefile.am b/client/Makefile.am
index 65868b8..aa261b7 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -1,6 +1,7 @@
 # 
-# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
-# 2014, 2015, 2016, 2017, 2018 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+#               2014, 2015, 2016, 2017, 2018, 2019
+# Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +25,8 @@ bin_PROGRAMS = pguru
 pguru_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/devices
 
 pguru_SOURCES = cmd.cc threads.cc
-pguru_LDADD = ../lib/libpguru.la -lboost_filesystem -lboost_system 
-lboost_regex -lpthread -ldl
+pguru_LDADD = ../lib/libpguru.la -lpthread -ldl
+# pguru_LDADD = ../lib/libpguru.la -lboost_filesystem -lboost_system 
-lboost_regex -lpthread -ldl
 # Use a GCC specs file to add our configured sysroot path before the
 # one specified by GCC to work around a problem when trying to
 # link executables fot the Raspberry PI using the normal cross gcc
diff --git a/client/cmd.cc b/client/cmd.cc
index 3730376..19b4784 100644
--- a/client/cmd.cc
+++ b/client/cmd.cc
@@ -43,7 +43,6 @@
 #include "tcpip.h"
 #include "ownet.h"
 
-extern LogFile dbglogfile;
 static void usage (const char *);
 
 const int INBUFSIZE = 1024;
@@ -58,6 +57,7 @@ main(int argc, char *argv[])
     std::string pserver = "localhost:" + DEFAULTPORT;
     retcode_t   ret;
 
+    log_init("pguru");
     // scan for the two main standard GNU options
     for (c=0; c<argc; c++) {
         if (strcmp("--help", argv[c]) == 0) {
@@ -77,7 +77,7 @@ main(int argc, char *argv[])
               break;
         
           case 'v':
-              dbglogfile.set_verbosity();
+              //dbglogfile.set_verbosity();
               break;
         
           case 'd':
@@ -104,10 +104,10 @@ main(int argc, char *argv[])
     Ownet ownet(pserver + ":4304");
     if (ownet.isConnected()) {
         if (ownet.hasSensors()) {
-            dbglogfile << "and has sensors attached" << std::endl;
+            BOOST_LOG(lg) << "and has sensors attached" << std::endl;
             ownet.dump();
         } else {
-            dbglogfile << "and has no sensors attached" << std::endl;
+            BOOST_LOG(lg) << "and has no sensors attached" << std::endl;
         }
     }
 #endif
diff --git a/client/threads.cc b/client/threads.cc
index a554bc2..aa1b38d 100644
--- a/client/threads.cc
+++ b/client/threads.cc
@@ -48,8 +48,6 @@ extern char *optarg;
 #include "xml.h"
 #include "commands.h"
 
-extern LogFile dbglogfile;
-
 using namespace std::chrono_literals;
 
 void
@@ -112,7 +110,7 @@ daemon_handler(Tcpip &net)
         while (loop) {
             data.clear();
             if (net.readNet(data).size() < 0) {
-                dbglogfile << "ERROR: Got error from socket " << std::endl;
+                BOOST_LOG(lg) << "ERROR: Got error from socket ";
                 loop = false;
             } else {
                 if (data.data() == 0) {
@@ -149,7 +147,7 @@ daemon_handler(Tcpip &net)
                 if (buffer[0] == '<') {
                     XML xml;
                     xml.parseMem(buffer);
-                    dbglogfile << "FIXME1: \"" << xml.nameGet() << "\"" << 
std::endl;
+                    BOOST_LOG(lg) << "FIXME1: \"" << xml.nameGet() << "\"";
                     if (xml.nameGet() == "command") {
                         std::cerr << "FIXME2: Command: " << xml.valueGet() << 
std::endl;
                         if (xml.valueGet() == "help") {
diff --git a/configure.ac b/configure.ac
index 3bb4f71..623a916 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,7 @@ AC_ARG_WITH(devices, [  --with-devices          the device(s) 
to build (ownet, o
 for i in ${devices}; do
     echo "FIXME: $i"
      case ${i} in
+        serial)  BUILD_SERIAL="yes" ;;
         ownet)  BUILD_OWNET="yes" ;;
         outback) BUILD_OUTBACK="yes" ;;
         xantrex) BUILD_XANTREX="yes" ;;
@@ -96,9 +97,13 @@ dnl AC_SUBST(BUILD_OWNET)
 dnl AC_SUBST(BUILD_OUTBACK)
 dnl AC_SUBST(BUILD_XANTREX)
 
+AM_CONDITIONAL(BUILD_SERIAL, [ test x${BUILD_SERIAL} = xyes ])
+if test x${BUILD_SERIAL} = xyes; then
+   AC_DEFINE([BUILD_SERIAL], [1], [Build support for serial ports])
+fi
 AM_CONDITIONAL(BUILD_OWNET, [ test x${BUILD_OWNET} = xyes ])
 if test x${BUILD_OWNET} = xyes; then
-   AC_DEFINE([BUILD_OWNET], [1], [Buikd support for owfs])
+   AC_DEFINE([BUILD_OWNET], [1], [Build support for owfs])
 fi
 AM_CONDITIONAL(BUILD_OUTBACK, [ test x${BUILD_OUTBACK} = xyes ])
 if test x${BUILD_OUTBACK} = xyes; then
@@ -386,7 +391,9 @@ if (test x"${has_boost_filesystem}" = x"no" \
    -o x"${has_boost_regex}" = x"no" -o x"${has_boost_system}" = x"np"); then
   AC_MSG_ERROR([You need all the boost libraries!])
 fi
-LIBS="-lboost_filesystem -lboost_system -lboost_regex"
+LIBS="-lboost_filesystem -lboost_system -lboost_regex -lboost_log 
-lboost_log_setup -lboost_thread"
+AC_DEFINE([BOOST_LOG_DYN_LINK], [1], [Force Boost::logging to be dynamically 
linked])
+dnl AC_DEFINE(]BOOST_ALL_DYN_LINK], [1], [Fo ])
 
 AC_MSG_CHECKING([For DejaGnu])
 AC_TRY_COMPILE([#include <dejagnu.h>], [
diff --git a/cross.spec b/cross.spec
index 900f533..778b60a 100644
--- a/cross.spec
+++ b/cross.spec
@@ -1,4 +1,3 @@
-%rename lib libc
-
-*lib:
-%(libc)
+%rename link_libgcc lgcc
+*link_libgcc:
+-rpath=%R/usr/local -L%R/lib/arm-linux-gnueabihf -L%R/lib/arm-linux-gnueabihf 
-L%R/usr/lib/arm-linux-gnueabihf 
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 6aa7709..671a655 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -1,5 +1,6 @@
 # 
-# Copyright (C) 2005, 2006-2018
+# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+#               2014, 2015, 2016, 2017, 2018, 2019
 #      Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -22,7 +23,8 @@ AUTOMAKE_OPTIONS = # dejagnu
 
 pgd_CPPFLAGS = -Wall -I$(top_srcdir)/lib -I$(top_srcdir)/devices
 pgd_LDADD = ../devices/libpdev.la ../lib/libpguru.la -lboost_filesystem \
-        -lboost_regex -lboost_system -lpthread -lresolv
+        -lboost_regex -lboost_system -lboost_log -lboost_log_setup \
+       -lpthread -lresolv -ldl
 
 if BUILD_LIBXML
 pgd_CPPFLAGS += $(LIBXML_CPPFLAGS)
@@ -45,7 +47,7 @@ endif
 bin_PROGRAMS = pgd
 
 pgd_SOURCES = main.cc threads.cc
-pgd_LDFLAGS = -export-dynamic -ldl
+# pgd_LDFLAGS += -export-dynamic -ldl
 
 # MUDFLAP_OPT = -fmudflap
 # MUDFLAP_LIB =  /usr/local/lib/libmudflap.so
diff --git a/daemon/main.cc b/daemon/main.cc
index ffd1481..5fa55a7 100644
--- a/daemon/main.cc
+++ b/daemon/main.cc
@@ -1,5 +1,7 @@
 // 
-// Copyright (C) 2005, 2006-2018 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+//               2014, 2015, 2016, 2017, 2018, 2019
+// Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -40,7 +42,6 @@ extern int optind;
 extern char *optarg;
 #endif
 
-// local header files
 #include "log.h"
 #ifdef BUILD_XANTREX
 include "xantrex-trace.h"
@@ -58,15 +59,13 @@ include "xantrex-trace.h"
 #include "snmp.h"
 #include "rc.h"
 #include "tcpip.h"
-#include "xml.h"
+//#include "xml.h"
 #include "serial.h"
 #include "commands.h"
 #include "onewire.h"
 
 using namespace rcinit;
 
-extern LogFile dbglogfile;
-
 static void usage (const char *);
 
 // Protoypes for the threads entry point
@@ -98,6 +97,8 @@ main(int argc, char *argv[])
     retcode_t   ret;
     std::condition_variable alldone;
 
+    log_init("pgd");
+    
     // scan for the two main standard GNU options
     for (c = 0; c < argc; c++) {
         if (strcmp("--help", argv[c]) == 0) {
@@ -134,8 +135,9 @@ main(int argc, char *argv[])
           case 'h':
               usage (argv[0]);
               break;
-
           case 'w':
+              // this string needs to include the port if it's
+              // not using the default one.
               owserver = strdup(optarg);
               break;
 #if 0
@@ -169,8 +171,8 @@ main(int argc, char *argv[])
 #endif
           case 'v':
               // verbosity++;
-              dbglogfile.set_verbosity();
-              dbglogfile << "Verbose output turned on" << std::endl;
+              //dbglogfile.set_verbosity();
+              BOOST_LOG(lg) << "Verbose output turned on" << std::endl;
               break;
        
           default:
@@ -187,7 +189,7 @@ main(int argc, char *argv[])
     }
 #endif
 
-    dbglogfile << "PowerGuru - 1 Wire Mode" << std::endl;
+    BOOST_LOG(lg) << "PowerGuru - 1 Wire Mode" << std::endl;
     Tcpip net;
     if (net.createNetServer(DEFAULTPORT) == ERROR) {
         std::cerr << "ERROR: Couldn't create a network server!" << std::endl;
@@ -228,7 +230,7 @@ main(int argc, char *argv[])
     }
 
     // synchronize threads:
-    dbglogfile << "Killing all threads..." << std::endl;
+    BOOST_LOG(lg) << "Killing all threads..." << std::endl;
     onewire_thread.join();      // pauses until first finishes
     client_thread.join();       // pauses until first finishes
 #ifdef BUILD_OWNET
diff --git a/daemon/threads.cc b/daemon/threads.cc
index d57ce70..a928bdb 100644
--- a/daemon/threads.cc
+++ b/daemon/threads.cc
@@ -50,8 +50,6 @@ extern char *optarg;
 #include "commands.h"
 #include "ownet.h"
 
-extern LogFile dbglogfile;
-
 using namespace std::chrono_literals;
 
 // This queue is used to pass data between the threads.
@@ -63,11 +61,17 @@ void
 onewire_handler(Onewire &onewire)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    dbglogfile << "PowerGuru - 1 Wire Mode" << std::endl;
+    BOOST_LOG(lg) << "PowerGuru - 1 Wire Mode";
+
+    if (!onewire.isMounted()) {
+        BOOST_LOG(lg) << "WARNING: Couldn't open 1wire file system!";
+        return;        
+    }
+    
 #ifdef HAVE_LIBPQ
     Database pdb;
     if (!pdb.openDB()) {
-        dbglogfile << "ERROR: Couldn't open database!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: Couldn't open database!";
         exit(1);
     }
 #endif
@@ -127,7 +131,7 @@ client_handler(Tcpip &net)
             data.clear();
             size_t pos = net.readNet(data).size();
             if (pos < 0) {
-                dbglogfile << "ERROR: Got error from socket " << std::endl;
+                BOOST_LOG(lg) << "ERROR: Got error from socket ";
                 //loop = false;
             } else {
                 if (data.data() == 0) {
@@ -161,8 +165,8 @@ client_handler(Tcpip &net)
                     if (xml[0]->nameGet() == "helo") {
                         hostname = xml[0]->childGet(0)->valueGet();
                         user =  xml[0]->childGet(1)->valueGet();
-                        dbglogfile << "Incoming connection from user " << user
-                                   << " on host " << hostname << std::endl;
+                        BOOST_LOG(lg) << "Incoming connection from user " << 
user
+                                   << " on host " << hostname;
                     } else {
                         cmd.execCommand(xml, str);
                         std::lock_guard<std::mutex> guard(queue_lock);
@@ -183,13 +187,18 @@ void
 ownet_handler(Ownet &ownet)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    dbglogfile << "PowerGuru - 1 Wire Mode" << std::endl;
-    bool poll = true;
+    BOOST_LOG(lg) << "PowerGuru - 1 Wire Mode";
+
+    if (!ownet.isConnected()) {
+        BOOST_LOG(lg) << "WARNING: Not connected to owserver!";
+        return;        
+    }
+    
 #ifdef HAVE_LIBPQ
     Database pdb;
     if (!pdb.openDB()) {
-        dbglogfile << "ERROR: Couldn't open database!" << std::endl;
-        exit(1);
+        BOOST_LOG(lg) << "ERROR: Couldn't open database!";
+        return;
     }
 #endif
 
@@ -198,13 +207,14 @@ ownet_handler(Ownet &ownet)
     query += "";
     query += ");";
 
-    std::map<std::string, ownet_t *> sensors = ownet.getSensors();
-    std::map<std::string, ownet_t *>::iterator it;
+    std::map<std::string, boost::shared_ptr<ownet_t>> 
sensors(ownet.getSensors());
+    std::map<std::string, boost::shared_ptr<ownet_t>>::iterator it;
     while (ownet.getPollSleep() > 0) {
         for (it = sensors.begin(); it != sensors.end(); it++) {
             if ((it->second->family == "10") | (it->second->family == "28")) {
-                boost::shared_ptr<temperature_t> temp = 
ownet.getTemperature(it->first.c_str());
+                boost::shared_ptr<temperature_t> 
temp(ownet.getTemperature(it->first.c_str()));
                 if (temp == 0) {
+                    BOOST_LOG(lg) << "ZERO!!!!";
                     continue;
                 }
 #ifdef HAVE_LIBPQ
@@ -283,11 +293,11 @@ outback_handler(Ownet &ownet)
         while (loop) {
             ret = msg.anydata(messages);
             if (ret == ERROR) {
-                dbglogfile << "ERROR: Got error from socket " << endl;
+                BOOST_LOG(lg) << "ERROR: Got error from socket " << endl;
                 msg.closeNet();
                 // wait for the next connection
                 if ((ret = msg.newNetConnection(true))) {
-                    dbglogfile << "New connection started for remote client."
+                    BOOST_LOG(lg) << "New connection started for remote 
client."
                                << msg.remoteIP().c_str()
                                << msg.remoteName().c_str() << endl;
                     ret = SUCCESS;        // the error has been handled
@@ -295,7 +305,7 @@ outback_handler(Ownet &ownet)
                 }
             }
             if (messages.size() == 0) {
-                dbglogfile << "ERROR: client socket shutdown! " << endl;
+                BOOST_LOG(lg) << "ERROR: client socket shutdown! " << endl;
             }
             for (i=0; i < messages.size(); i++) {
                 cerr << "Got (" << messages.size() << ") messages " << 
messages[i] << endl;
@@ -313,7 +323,7 @@ outback_handler(Ownet &ownet)
     }
 #endif
 
-    dbglogfile << "FIXME: outback_handler() unimplemented"<< std::endl;
+    BOOST_LOG(lg) << "FIXME: outback_handler() unimplemented"<< std::endl;
     // Don't eat up all the cpu cycles!
     std::this_thread::sleep_for(std::chrono::seconds(ownet.getPollSleep()));
 }
@@ -334,7 +344,7 @@ xantrex_handler(Ownet &ownet)
     hostname = "localhost";
 #endif
 
-    dbglogfile << "FIXME: xantrext_handler() unimplemented"<< std::endl;
+    BOOST_LOG(lg) << "FIXME: xantrext_handler() unimplemented"<< std::endl;
     // Don't eat up all the cpu cycles!
     std::this_thread::sleep_for(std::chrono::seconds(ownet.getPollSleep()));
 }
diff --git a/depcomp b/depcomp
index 11e2d3b..65cbf70 100755
--- a/depcomp
+++ b/depcomp
@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2004-05-31.23
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,9 +16,7 @@ scriptversion=2004-05-31.23
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -29,9 +27,9 @@ scriptversion=2004-05-31.23
 
 case $1 in
   '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
-     exit 1;
-     ;;
+    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+    exit 1;
+    ;;
   -h | --h*)
     cat <<\EOF
 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
@@ -41,23 +39,83 @@ as side-effects.
 
 Environment variables:
   depmode     Dependency tracking mode.
-  source      Source file read by `PROGRAMS ARGS'.
-  object      Object file output by `PROGRAMS ARGS'.
+  source      Source file read by 'PROGRAMS ARGS'.
+  object      Object file output by 'PROGRAMS ARGS'.
   DEPDIR      directory where to store dependencies.
   depfile     Dependency file to output.
-  tmpdepfile  Temporary file to use when outputing dependencies.
+  tmpdepfile  Temporary file to use when outputting dependencies.
   libtool     Whether libtool is used (yes/no).
 
 Report bugs to <address@hidden>.
 EOF
-    exit 0
+    exit $?
     ;;
   -v | --v*)
     echo "depcomp $scriptversion"
-    exit 0
+    exit $?
     ;;
 esac
 
+# Get the directory component of the given path, and save it in the
+# global variables '$dir'.  Note that this directory component will
+# be either empty or ending with a '/' character.  This is deliberate.
+set_dir_from ()
+{
+  case $1 in
+    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
+      *) dir=;;
+  esac
+}
+
+# Get the suffix-stripped basename of the given path, and save it the
+# global variable '$base'.
+set_base_from ()
+{
+  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
+}
+
+# If no dependency file was actually created by the compiler invocation,
+# we still have to create a dummy depfile, to avoid errors with the
+# Makefile "include basename.Plo" scheme.
+make_dummy_depfile ()
+{
+  echo "#dummy" > "$depfile"
+}
+
+# Factor out some common post-processing of the generated depfile.
+# Requires the auxiliary global variable '$tmpdepfile' to be set.
+aix_post_process_depfile ()
+{
+  # If the compiler actually managed to produce a dependency file,
+  # post-process it.
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form 'foo.o: dependency.h'.
+    # Do two passes, one to just change these to
+    #   $object: dependency.h
+    # and one to simply output
+    #   dependency.h:
+    # which is needed to avoid the deleted-header problem.
+    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
+      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
+    } > "$depfile"
+    rm -f "$tmpdepfile"
+  else
+    make_dummy_depfile
+  fi
+}
+
+# A tabulation character.
+tab='  '
+# A newline character.
+nl='
+'
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   echo "depcomp: Variables source, object and depmode must be set" 1>&2
   exit 1
@@ -70,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 
's/\.\([^.]*\)$/.T\1/'`}
 
 rm -f "$tmpdepfile"
 
+# Avoid interferences from the environment.
+gccflag= dashmflag=
+
 # Some modes work just like other modes, but use different flags.  We
 # parameterize here, but still list the modes in the big case below,
 # to make depend.m4 easier to write.  Note that we *cannot* use a case
@@ -81,9 +142,32 @@ if test "$depmode" = hp; then
 fi
 
 if test "$depmode" = dashXmstdout; then
-   # This is just like dashmstdout with a different argument.
-   dashmflag=-xM
-   depmode=dashmstdout
+  # This is just like dashmstdout with a different argument.
+  dashmflag=-xM
+  depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+  # This is just like msvisualcpp but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvisualcpp
+fi
+
+if test "$depmode" = msvc7msys; then
+  # This is just like msvc7 but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvc7
+fi
+
+if test "$depmode" = xlc; then
+  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
+  gccflag=-qmakedep=gcc,-MF
+  depmode=gcc
 fi
 
 case "$depmode" in
@@ -91,10 +175,22 @@ gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
 ## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
 ## it if -MD -MP comes after the -MF stuff.  Hmm.
-  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -102,13 +198,17 @@ gcc3)
   ;;
 
 gcc)
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## (see the conditional assignment to $gccflag above).
 ## There are various ways to get dependency output from gcc.  Here's
 ## why we pick this rather obscure method:
 ## - Don't want to use -MD because we'd like the dependencies to end
 ##   up in a subdir.  Having to rename by hand is ugly.
 ##   (We might end up doing this anyway to support other compilers.)
 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-##   -MM, not -M (despite what the docs say).
+##   -MM, not -M (despite what the docs say).  Also, it might not be
+##   supported by the other compilers which use the 'gcc' depmode.
 ## - Using -M directly means running the compiler twice (even worse
 ##   than renaming).
   if test -z "$gccflag"; then
@@ -116,31 +216,31 @@ gcc)
   fi
   "$@" -Wp,"$gccflag$tmpdepfile"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
+  # The second -e expression handles DOS-style file names with drive
+  # letters.
   sed -e 's/^[^:]*: / /' \
       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
+## This next piece of magic avoids the "deleted header file" problem.
 ## The problem is that when a header file which appears in a .P file
 ## is deleted, the dependency causes make to die (because there is
 ## typically no way to rebuild the header).  We avoid this by adding
 ## dummy dependencies for each header file.  Too bad gcc doesn't do
 ## this for us directly.
-  tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'.  On the theory
+## Some versions of gcc put a space before the ':'.  On the theory
 ## that the space means something, we add a space to the output as
-## well.
+## well.  hp depmode also adds that space, but also prefixes the VPATH
+## to the object.  Take care to not repeat it in the output.
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -158,8 +258,7 @@ sgi)
     "$@" -MDupdate "$tmpdepfile"
   fi
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -167,99 +266,156 @@ sgi)
 
   if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
     echo "$object : \\" > "$depfile"
-
     # Clip off the initial element (the dependent).  Don't try to be
     # clever and replace this with sed code, as IRIX sed won't handle
     # lines with more than a fixed number of characters (4096 in
     # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
-    # the IRIX cc adds comments like `#:fec' to the end of the
+    # the IRIX cc adds comments like '#:fec' to the end of the
     # dependency line.
-    tr ' ' '
-' < "$tmpdepfile" \
-    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> $depfile
-    echo >> $depfile
-
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
+      | tr "$nl" ' ' >> "$depfile"
+    echo >> "$depfile"
     # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
-   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> $depfile
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+      >> "$depfile"
   else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
+    make_dummy_depfile
   fi
   rm -f "$tmpdepfile"
   ;;
 
+xlc)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 aix)
   # The C for AIX Compiler uses -M and outputs the dependencies
   # in a .u file.  In older versions, this file always lives in the
-  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # current directory.  Also, the AIX compiler puts '$object:' at the
   # start of each line; $object doesn't have directory information.
   # Version 6 uses the directory in both cases.
-  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
-  tmpdepfile="$stripped.u"
+  set_dir_from "$object"
+  set_base_from "$object"
   if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
     "$@" -Wc,-M
   else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
     "$@" -M
   fi
   stat=$?
-
-  if test -f "$tmpdepfile"; then :
-  else
-    stripped=`echo "$stripped" | sed 's,^.*/,,'`
-    tmpdepfile="$stripped.u"
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
   fi
 
-  if test $stat -eq 0; then :
-  else
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  aix_post_process_depfile
+  ;;
+
+tcc)
+  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
+  # FIXME: That version still under development at the moment of writing.
+  #        Make that this statement remains true also for stable, released
+  #        versions.
+  # It will wrap lines (doesn't matter whether long or short) with a
+  # trailing '\', as in:
+  #
+  #   foo.o : \
+  #    foo.c \
+  #    foo.h \
+  #
+  # It will put a trailing '\' even on the last line, and will use leading
+  # spaces rather than leading tabs (at least since its commit 0394caf7
+  # "Emit spaces for -MD").
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
-
-  if test -f "$tmpdepfile"; then
-    outname="$stripped.o"
-    # Each line is of the form `foo.o: dependent.h'.
-    # Do two passes, one to just change these to
-    # `$object: dependent.h' and one to simply `dependent.h:'.
-    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
-    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
-  fi
+  rm -f "$depfile"
+  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
+  # We have to change lines of the first kind to '$object: \'.
+  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
+  # And for each line of the second kind, we have to emit a 'dep.h:'
+  # dummy dependency, to avoid the deleted-header problem.
+  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
-icc)
-  # Intel's C compiler understands `-MD -MF file'.  However on
-  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
-  # ICC 7.0 will fill foo.d with something like
-  #    foo.o: sub/foo.c
-  #    foo.o: sub/foo.h
-  # which is wrong.  We want:
-  #    sub/foo.o: sub/foo.c
-  #    sub/foo.o: sub/foo.h
-  #    sub/foo.c:
-  #    sub/foo.h:
-  # ICC 7.1 will output
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file.  A plain '-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+  # Portland's C compiler understands '-MD'.
+  # Will always output deps to 'file.d' where file is the root name of the
+  # source file under compilation, even if file resides in a subdirectory.
+  # The object file name does not affect the name of the '.d' file.
+  # pgcc 10.2 will output
   #    foo.o: sub/foo.c sub/foo.h
-  # and will wrap long lines using \ :
+  # and will wrap long lines using '\' :
   #    foo.o: sub/foo.c ... \
   #     sub/foo.h ... \
   #     ...
+  set_dir_from "$object"
+  # Use the source, not the object, to determine the base name, since
+  # that's sadly what pgcc will do too.
+  set_base_from "$source"
+  tmpdepfile=$base.d
+
+  # For projects that build the same source file twice into different object
+  # files, the pgcc approach of using the *source* file root name can cause
+  # problems in parallel builds.  Use a locking strategy to avoid stomping on
+  # the same $tmpdepfile.
+  lockdir=$base.d-lock
+  trap "
+    echo '$0: caught signal, cleaning up...' >&2
+    rmdir '$lockdir'
+    exit 1
+  " 1 2 13 15
+  numtries=100
+  i=$numtries
+  while test $i -gt 0; do
+    # mkdir is a portable test-and-set.
+    if mkdir "$lockdir" 2>/dev/null; then
+      # This process acquired the lock.
+      "$@" -MD
+      stat=$?
+      # Release the lock.
+      rmdir "$lockdir"
+      break
+    else
+      # If the lock is being held by a different process, wait
+      # until the winning process is done or we timeout.
+      while test -d "$lockdir" && test $i -gt 0; do
+        sleep 1
+        i=`expr $i - 1`
+      done
+    fi
+    i=`expr $i - 1`
+  done
+  trap - 1 2 13 15
+  if test $i -le 0; then
+    echo "$0: failed to acquire lock after $numtries attempts" >&2
+    echo "$0: check lockdir '$lockdir'" >&2
+    exit 1
+  fi
 
-  "$@" -MD -MF "$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -271,61 +427,141 @@ icc)
   sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
   # Some versions of the HPUX 10.20 sed can't process this invocation
   # correctly.  Breaking it into two sed invocations is a workaround.
-  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
-    sed -e 's/$/ :/' >> "$depfile"
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  set_dir_from  "$object"
+  set_base_from "$object"
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -ne 0; then
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add 'dependent.h:' lines.
+    sed -ne '2,${
+               s/^ *//
+               s/ \\*$//
+               s/$/:/
+               p
+             }' "$tmpdepfile" >> "$depfile"
+  else
+    make_dummy_depfile
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
 tru64)
-   # The Tru64 compiler uses -MD to generate dependencies as a side
-   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
-   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
-   # dependencies in `foo.d' instead, so we check for that too.
-   # Subdirectories are respected.
-   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-   test "x$dir" = "x$object" && dir=
-   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
-   if test "$libtool" = yes; then
-      # Dependencies are output in .lo.d with libtool 1.4.
-      # With libtool 1.5 they are output both in $dir.libs/$base.o.d
-      # and in $dir.libs/$base.o.d and $dir$base.o.d.  We process the
-      # latter, because the former will be cleaned when $dir.libs is
-      # erased.
-      tmpdepfile1="$dir.libs/$base.lo.d"
-      tmpdepfile2="$dir$base.o.d"
-      tmpdepfile3="$dir.libs/$base.d"
-      "$@" -Wc,-MD
-   else
-      tmpdepfile1="$dir$base.o.d"
-      tmpdepfile2="$dir$base.d"
-      tmpdepfile3="$dir$base.d"
-      "$@" -MD
-   fi
-
-   stat=$?
-   if test $stat -eq 0; then :
-   else
-      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
-      exit $stat
-   fi
-
-   if test -f "$tmpdepfile1"; then
-      tmpdepfile="$tmpdepfile1"
-   elif test -f "$tmpdepfile2"; then
-      tmpdepfile="$tmpdepfile2"
-   else
-      tmpdepfile="$tmpdepfile3"
-   fi
-   if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a tab and a space in the [].
-      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-   else
-      echo "#dummy" > "$depfile"
-   fi
-   rm -f "$tmpdepfile"
-   ;;
+  # The Tru64 compiler uses -MD to generate dependencies as a side
+  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
+  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+  # dependencies in 'foo.d' instead, so we check for that too.
+  # Subdirectories are respected.
+  set_dir_from  "$object"
+  set_base_from "$object"
+
+  if test "$libtool" = yes; then
+    # Libtool generates 2 separate objects for the 2 libraries.  These
+    # two compilations output dependencies in $dir.libs/$base.o.d and
+    # in $dir$base.o.d.  We have to check for both files, because
+    # one of the two compilations can be disabled.  We should prefer
+    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+    # automatically cleaned when .libs/ is deleted, while ignoring
+    # the former would cause a distcleancheck panic.
+    tmpdepfile1=$dir$base.o.d          # libtool 1.5
+    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
+    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
+    "$@" -Wc,-MD
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    tmpdepfile3=$dir$base.d
+    "$@" -MD
+  fi
+
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  # Same post-processing that is required for AIX mode.
+  aix_post_process_depfile
+  ;;
+
+msvc7)
+  if test "$libtool" = yes; then
+    showIncludes=-Wc,-showIncludes
+  else
+    showIncludes=-showIncludes
+  fi
+  "$@" $showIncludes > "$tmpdepfile"
+  stat=$?
+  grep -v '^Note: including file: ' "$tmpdepfile"
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  # The first sed program below extracts the file names and escapes
+  # backslashes for cygpath.  The second sed program outputs the file
+  # name when reading, but also accumulates all include files in the
+  # hold buffer in order to output them again at the end.  This only
+  # works with sed implementations that can handle large buffers.
+  sed < "$tmpdepfile" -n '
+/^Note: including file:  *\(.*\)/ {
+  s//\1/
+  s/\\/\\\\/g
+  p
+}' | $cygpath_u | sort -u | sed -n '
+s/ /\\ /g
+s/\(.*\)/'"$tab"'\1 \\/p
+s/.\(.*\) \\/\1:/
+H
+$ {
+  s/.*/'"$tab"'/
+  G
+  p
+}' >> "$depfile"
+  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
+  rm -f "$tmpdepfile"
+  ;;
+
+msvc7msys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
 
 #nosideeffect)
   # This comment above is used by automake to tell side-effect
@@ -338,13 +574,13 @@ dashmstdout)
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -364,18 +600,18 @@ dashmstdout)
   done
 
   test -z "$dashmflag" && dashmflag=-M
-  # Require at least two characters before searching for `:'
+  # Require at least two characters before searching for ':'
   # in the target name.  This is to cope with DOS-style filenames:
-  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
   "$@" $dashmflag |
-    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this sed invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -389,41 +625,51 @@ makedepend)
   "$@" || exit $?
   # Remove any Libtool call
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
   # X makedepend
   shift
-  cleared=no
-  for arg in "$@"; do
+  cleared=no eat=no
+  for arg
+  do
     case $cleared in
     no)
       set ""; shift
       cleared=yes ;;
     esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
     case "$arg" in
     -D*|-I*)
       set fnord "$@" "$arg"; shift ;;
     # Strip any option that makedepend may not understand.  Remove
     # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
     -*|$object)
       ;;
     *)
       set fnord "$@" "$arg"; shift ;;
     esac
   done
-  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
   touch "$tmpdepfile"
   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  # makedepend may prepend the VPATH from the source file name to the object.
+  # No need to regex-escape $object, excess matching of '.' is harmless.
+  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process the last invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed '1,2d' "$tmpdepfile" \
+    | tr ' ' "$nl" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile" "$tmpdepfile".bak
   ;;
 
@@ -434,13 +680,13 @@ cpp)
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -459,9 +705,10 @@ cpp)
     esac
   done
 
-  "$@" -E |
-    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
-    sed '$ s: \\$::' > "$tmpdepfile"
+  "$@" -E \
+    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+    | sed '$ s: \\$::' > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
   cat < "$tmpdepfile" >> "$depfile"
@@ -471,35 +718,56 @@ cpp)
 
 msvisualcpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
+  # always write the preprocessed file to stdout.
   "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
   IFS=" "
   for arg
   do
     case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
-       set fnord "$@"
-       shift
-       shift
-       ;;
+        set fnord "$@"
+        shift
+        shift
+        ;;
     *)
-       set fnord "$@" "$arg"
-       shift
-       shift
-       ;;
+        set fnord "$@" "$arg"
+        shift
+        shift
+        ;;
     esac
   done
-  "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' 
| sort | uniq > "$tmpdepfile"
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > 
"$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> 
"$depfile"
-  echo "       " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> 
"$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> 
"$depfile"
+  echo "$tab" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 none)
   exec "$@"
   ;;
@@ -515,8 +783,9 @@ exit 0
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/devices/onewire.cc b/devices/onewire.cc
index 293706d..609d8b2 100644
--- a/devices/onewire.cc
+++ b/devices/onewire.cc
@@ -22,8 +22,7 @@
 #include <iostream>
 #include <cstdio>
 #include "onewire.h"
-
-extern LogFile dbglogfile;
+#include "log.h"
 
 Onewire::Onewire(void)
     : _scale('F'),
@@ -31,7 +30,7 @@ Onewire::Onewire(void)
     _mounted(false),
     _rootdir("/mnt/1wire")
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     boost::filesystem::path p(_rootdir);
     try {
@@ -64,7 +63,7 @@ void
 Onewire::setValue(const std::string &device, const std::string &file,
                   const std::string &value)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     // Don't try to do anything if the owfs isn't mounted and we somehow got 
here anyway.
     if (!_mounted) {
@@ -108,7 +107,7 @@ Onewire::getValue(const std::string &device, std::string 
file, std::string &resu
         entry >> result;
         entry.close();
     } catch (const std::exception& e) {
-        dbglogfile << "Warning: iostream failure! " << e.what() << std::endl;
+        BOOST_LOG(lg) << "Warning: iostream failure! " << e.what();
     }
     //std::cerr << "Getting " << filespec << ", value: " << result<< std::endl;
     return result;
@@ -142,7 +141,7 @@ Onewire::getTemperatures(void)
 void
 Onewire::dump(void)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     std::map<std::string, boost::shared_ptr<onewire_t>>::iterator sit;
     for (sit = _sensors.begin(); sit != _sensors.end(); sit++) {
diff --git a/devices/onewire.h b/devices/onewire.h
index 7f27ba3..160eb29 100644
--- a/devices/onewire.h
+++ b/devices/onewire.h
@@ -27,8 +27,6 @@
 #include <boost/filesystem.hpp>
 #include "log.h"
 
-extern LogFile dbglogfile;
-
 struct onewire {
     std::string family;
     std::string id;
diff --git a/devices/outbackpower.cc b/devices/outbackpower.cc
index 94d9e65..1fc0c64 100644
--- a/devices/outbackpower.cc
+++ b/devices/outbackpower.cc
@@ -70,7 +70,7 @@ outback::readSerial()
     ret = Read(buf, PACKET_SIZE);
   
     if (ret > 0) {
-        //dbglogfile << "FIXME3: Read " << ret << " bytes: " << buf << "\t" << 
buf << endl;
+        //BOOST_LOG(lg) << "FIXME3: Read " << ret << " bytes: " << buf << "\t" 
<< buf << endl;
         return buf;
     }
 
@@ -85,7 +85,7 @@ outback::commInit(string filespec)
     DEBUGLOG_REPORT_FUNCTION;
 
     if (filespec.size() == 0) {
-        dbglogfile << "ERROR: no serial device specified!" << endl;
+        BOOST_LOG(lg) << "ERROR: no serial device specified!" << endl;
         exit(0);
     }    
 
@@ -93,7 +93,7 @@ outback::commInit(string filespec)
         Open(filespec);
     }
     catch (ErrCond catch_err) {
-        dbglogfile << catch_err << endl;
+        BOOST_LOG(lg) << catch_err << endl;
         exit(1);
     }
   
@@ -229,7 +229,7 @@ retcode_t outback::parse(const char *data)
     } else if ((_address >= 'A') && (_address <= 'K')) {
         _type = OUTBACK_MX;
     } else {
-        dbglogfile << "ERROR: bad address in packet!" << endl;
+        BOOST_LOG(lg) << "ERROR: bad address in packet!" << endl;
         return ERROR;
     }
 
@@ -320,14 +320,14 @@ outback::dump()
 {
     switch (_type) {
       case OUTBACK_MX:
-          dbglogfile << "Outback Power Systems MX Charge Controller" << endl;
+          BOOST_LOG(lg) << "Outback Power Systems MX Charge Controller" << 
endl;
           break;
       case OUTBACK_FX:
-          dbglogfile << "Outback Power Systems FX inverter" << endl;
+          BOOST_LOG(lg) << "Outback Power Systems FX inverter" << endl;
           break;
       case OUTBACK_NONE:
       default:
-          dbglogfile << "Outback Power Systems, no type specified!" << endl;
+          BOOST_LOG(lg) << "Outback Power Systems, no type specified!" << endl;
           break;
     };
   
@@ -339,247 +339,247 @@ outback::dump()
     } else if ((_address >= 'A') && (_address <= 'K')) {
         addr += _address;
     }
-    dbglogfile << "The address is: " << addr.c_str() << endl;
+    BOOST_LOG(lg) << "The address is: " << addr.c_str() << endl;
 
     // Amperage readings. These range from 0-99 in 1 amp increments
     if (_inverter_current) {
-        dbglogfile << "Inverter current is: " << _inverter_current << endl;
+        BOOST_LOG(lg) << "Inverter current is: " << _inverter_current << endl;
     }
 
     if (_charge_current) {
-        dbglogfile << "Charge current is: " << _charge_current << " Amps" << 
endl;
+        BOOST_LOG(lg) << "Charge current is: " << _charge_current << " Amps" 
<< endl;
     }
     if (_buy_current) {
-        dbglogfile << "Buy current is: " <<  _buy_current << " Amps" << endl;
+        BOOST_LOG(lg) << "Buy current is: " <<  _buy_current << " Amps" << 
endl;
     }
     if (_pv_current) {
-        dbglogfile << "PV current is: " <<  _pv_current << " Amps" << endl;
+        BOOST_LOG(lg) << "PV current is: " <<  _pv_current << " Amps" << endl;
     }
     if (_sell_current) {
-        dbglogfile << "Sell current is: " <<  _sell_current << " Amps" << endl;
+        BOOST_LOG(lg) << "Sell current is: " <<  _sell_current << " Amps" << 
endl;
     }
 
     // Voltage readings. These range from 0-256. If the Misc Mode bit is
     // set, then this number is multiplied by 2.
     if (_AC_input_voltage) {
-        dbglogfile << "AC Input voltage is: " << _AC_input_voltage << " VAC" 
<< endl;
+        BOOST_LOG(lg) << "AC Input voltage is: " << _AC_input_voltage << " 
VAC" << endl;
     }
     if (_AC_output_voltage) {
-        dbglogfile << "AC Output voltage is: " << _AC_output_voltage << " VAC" 
<< endl;
+        BOOST_LOG(lg) << "AC Output voltage is: " << _AC_output_voltage << " 
VAC" << endl;
     }
     // one volt increments, ignore the misc Byte. FIXME: Do we devide this by 
2 ?
     if (_pv_input_voltage) {
-        dbglogfile << "PV Input voltage is: " << _pv_input_voltage/2 << " VDC" 
<< endl;
+        BOOST_LOG(lg) << "PV Input voltage is: " << _pv_input_voltage/2 << " 
VDC" << endl;
     }
   
     // the resolution is 0.1 volts for a 12VDC system, 0.2 volts for a
     // 24VDC system, and 0.4 for a 48 volt system.
     if (_battery_voltage) {
-        dbglogfile << "Battery voltage is: " << _battery_voltage/10
+        BOOST_LOG(lg) << "Battery voltage is: " << _battery_voltage/10
                    << "." << _battery_voltage%10 << " VDC" << endl;
     }
     // The total kilowatts used daily. This ranges from 0-999, with the
     // last digit being the fraction. ie... 99 = 99.9.
     if (_daily_kwh) {
-        dbglogfile << "The daily Kilowatts used is: " << _daily_kwh/10
+        BOOST_LOG(lg) << "The daily Kilowatts used is: " << _daily_kwh/10
                    << "." << _daily_kwh%10 << " KW" << endl;
     }
 
     // Modes. Not all modes are currently implemented on the MX
     // series. All the modes range from 0-99 except for the error and
     // warning modes which range from 0-256.
-    dbglogfile << "The operating mode is: ";
+    BOOST_LOG(lg) << "The operating mode is: ";
     switch (_operating_mode){
       case INV_OFF:
-          dbglogfile << "Inverter OFF" << endl;
+          BOOST_LOG(lg) << "Inverter OFF" << endl;
           break;
       case INV_SEARCH:
-          dbglogfile << "Inverter SEARCH" << endl;
+          BOOST_LOG(lg) << "Inverter SEARCH" << endl;
           break;
       case INV_ON:
-          dbglogfile << "Inverter ON" << endl;    
+          BOOST_LOG(lg) << "Inverter ON" << endl;    
           break;
       case CHARGE:
-          dbglogfile << "Charge" << endl;
+          BOOST_LOG(lg) << "Charge" << endl;
           break;
       case SILENT:
-          dbglogfile << "Silent" << endl;
+          BOOST_LOG(lg) << "Silent" << endl;
           break;
       case FLOAT:
-          dbglogfile << "Float" << endl;
+          BOOST_LOG(lg) << "Float" << endl;
           break;
       case EQ:
-          dbglogfile << "Equalize" << endl;
+          BOOST_LOG(lg) << "Equalize" << endl;
           break;
       case CHARGER_OFF:
-          dbglogfile << "Charger Off" << endl;
+          BOOST_LOG(lg) << "Charger Off" << endl;
           break;
       case SUPPORT:
-          dbglogfile << "Support" << endl;
+          BOOST_LOG(lg) << "Support" << endl;
           break;
       case SELL_ON:
-          dbglogfile << "Sell On" << endl;
+          BOOST_LOG(lg) << "Sell On" << endl;
           break;
       case PASS_THRU:
-          dbglogfile << "Pass Thru" << endl;
+          BOOST_LOG(lg) << "Pass Thru" << endl;
           break;
       case FX_ERR:
-          dbglogfile << "FX Error" << endl;
+          BOOST_LOG(lg) << "FX Error" << endl;
           break;
       case AGS_ERR:
-          dbglogfile << "AGS Error" << endl;
+          BOOST_LOG(lg) << "AGS Error" << endl;
           break;
       case COM_ERR:
-          dbglogfile << "Communications Error" << endl;
+          BOOST_LOG(lg) << "Communications Error" << endl;
           break;
       default:
-          dbglogfile << "No operating mode!" << endl;
+          BOOST_LOG(lg) << "No operating mode!" << endl;
           break;
     };
   
-    dbglogfile << "The AC mode is: \t";
+    BOOST_LOG(lg) << "The AC mode is: \t";
     switch (_AC_mode) {
       case NO_AC:
-          dbglogfile << "No AC" << endl;
+          BOOST_LOG(lg) << "No AC" << endl;
           break;
       case AC_DROP:
-          dbglogfile << "AC Dropped" << endl;
+          BOOST_LOG(lg) << "AC Dropped" << endl;
           break;
       case AC_USE:
-          dbglogfile << "AC In Use" << endl;    
+          BOOST_LOG(lg) << "AC In Use" << endl;    
           break;
       default:
-          dbglogfile << "No AC mode!" << endl;
+          BOOST_LOG(lg) << "No AC mode!" << endl;
           break;
     };
 
-    dbglogfile << "The Misc Byte is: \t";
+    BOOST_LOG(lg) << "The Misc Byte is: \t";
     switch (_misc_byte) {
       case 0:
-          dbglogfile << "No Misc byte" << endl;
+          BOOST_LOG(lg) << "No Misc byte" << endl;
       case AC_UNIT:
-          dbglogfile << "AC Unit" << endl;
+          BOOST_LOG(lg) << "AC Unit" << endl;
           break;
       case AUX_OUT_ON:
-          dbglogfile << "Aux Mode On set" << endl;
+          BOOST_LOG(lg) << "Aux Mode On set" << endl;
           break;
       default:
-          dbglogfile << "Reserved" << endl;
+          BOOST_LOG(lg) << "Reserved" << endl;
           break;
     };
 
-    dbglogfile << "The Aux mode is: \t";
+    BOOST_LOG(lg) << "The Aux mode is: \t";
     switch (_aux_mode) {
       case DISABLED:
-          dbglogfile << "Aux Mode Disabled" << endl;
+          BOOST_LOG(lg) << "Aux Mode Disabled" << endl;
           break;
       case DIVERSION:
-          dbglogfile << "Diversion" << endl;
+          BOOST_LOG(lg) << "Diversion" << endl;
           break;
       case REMOTE:
-          dbglogfile << "Remote" << endl;
+          BOOST_LOG(lg) << "Remote" << endl;
           break;
       case MANUAL:
-          dbglogfile << "Manual" << endl;
+          BOOST_LOG(lg) << "Manual" << endl;
           break;
       case VENT_FAN:
-          dbglogfile << "Vent Fan" << endl;
+          BOOST_LOG(lg) << "Vent Fan" << endl;
           break;
       case PV_TRIGGER:
-          dbglogfile << "PV Trigger" << endl;
+          BOOST_LOG(lg) << "PV Trigger" << endl;
           break;
       default:
-          dbglogfile << "No AUX mode set" << endl;
+          BOOST_LOG(lg) << "No AUX mode set" << endl;
           break;
     };
 
-    dbglogfile << "The charge mode is: \t";
+    BOOST_LOG(lg) << "The charge mode is: \t";
     switch (_charge_mode) {
       case SILENT_MODE:
-          dbglogfile << "Silent Charge mode" << endl;
+          BOOST_LOG(lg) << "Silent Charge mode" << endl;
           break;
       case FLOAT_MODE:
-          dbglogfile << "Float Charge mode" << endl;
+          BOOST_LOG(lg) << "Float Charge mode" << endl;
           break;
       case BULK_MODE:
-          dbglogfile << "Bulk Charge mode" << endl;
+          BOOST_LOG(lg) << "Bulk Charge mode" << endl;
           break;
       case ABSORB_MODE:
-          dbglogfile << "Absorb Charge mode" << endl;
+          BOOST_LOG(lg) << "Absorb Charge mode" << endl;
           break;
       case EQ_MODE:
-          dbglogfile << "Equalization Charge mode" << endl;
+          BOOST_LOG(lg) << "Equalization Charge mode" << endl;
           break;
       default:
-          dbglogfile << "No Charge mode" << endl;
+          BOOST_LOG(lg) << "No Charge mode" << endl;
           break;
     };
 
-    dbglogfile << "The error mode is: \t";
+    BOOST_LOG(lg) << "The error mode is: \t";
     switch (_error_mode) {
       case NO_ERROR:
-          dbglogfile << "No error" << endl;
+          BOOST_LOG(lg) << "No error" << endl;
           break;
       case LOW_VAC:
-          dbglogfile << "ERROR: Low Volts AC" << endl;
+          BOOST_LOG(lg) << "ERROR: Low Volts AC" << endl;
           break;
       case STACKING:
-          dbglogfile << "ERROR: Stacking" << endl;
+          BOOST_LOG(lg) << "ERROR: Stacking" << endl;
           break;
       case OVER_TEMP:
-          dbglogfile << "ERROR: Over Temperature" << endl;
+          BOOST_LOG(lg) << "ERROR: Over Temperature" << endl;
           break;
       case LOW_BATT:
-          dbglogfile << "ERROR: Low Battery" << endl;
+          BOOST_LOG(lg) << "ERROR: Low Battery" << endl;
           break;
       case PHASE_LOSS:
-          dbglogfile << "ERROR: Phase Loss" << endl;
+          BOOST_LOG(lg) << "ERROR: Phase Loss" << endl;
           break;
       case HIGH_BATT:
-          dbglogfile << "ERROR: High Battery" << endl;
+          BOOST_LOG(lg) << "ERROR: High Battery" << endl;
           break;
       case SHORT:
-          dbglogfile << "ERROR: Short" << endl;
+          BOOST_LOG(lg) << "ERROR: Short" << endl;
           break;
       case BACKFEED:
-          dbglogfile << "ERROR: Backfeed" << endl;
+          BOOST_LOG(lg) << "ERROR: Backfeed" << endl;
           break;
       default:
-          dbglogfile << "No error mode" << endl;
+          BOOST_LOG(lg) << "No error mode" << endl;
           break;
     };
 
-    dbglogfile << "The warning mode is: \t";
+    BOOST_LOG(lg) << "The warning mode is: \t";
     switch (_warning_mode) {
       case NO_WARNING:
-          dbglogfile << "No warning" << endl;
+          BOOST_LOG(lg) << "No warning" << endl;
           break;
       case AC_IN_FREQ_HIGH:
-          dbglogfile << "WARNING: Input Frequency High" << endl;
+          BOOST_LOG(lg) << "WARNING: Input Frequency High" << endl;
           break;
       case AC_IN_FREQ_LOW:
-          dbglogfile << "WARNING: Input Frequency Low" << endl;
+          BOOST_LOG(lg) << "WARNING: Input Frequency Low" << endl;
           break;
       case IN_VAC_HIGH:
-          dbglogfile << "WARNING: Input Volts AC High" << endl;
+          BOOST_LOG(lg) << "WARNING: Input Volts AC High" << endl;
           break;
       case IN_VAC_LOW:
-          dbglogfile << "WARNING: Input Volts AC low" << endl;
+          BOOST_LOG(lg) << "WARNING: Input Volts AC low" << endl;
           break;
       case BUY_IN_SIZE:
-          dbglogfile << "WARNING: Buy in size" << endl;
+          BOOST_LOG(lg) << "WARNING: Buy in size" << endl;
           break;
       case TEMP_FAILED:
-          dbglogfile << "WARNING: Temperature Failure" << endl;
+          BOOST_LOG(lg) << "WARNING: Temperature Failure" << endl;
           break;
       case COMM_ERROR:
-          dbglogfile << "WARNING: Communications error" << endl;
+          BOOST_LOG(lg) << "WARNING: Communications error" << endl;
           break;
       case FAN_FAILURE:
-          dbglogfile << "WARNING: Fan Failure" << endl;
+          BOOST_LOG(lg) << "WARNING: Fan Failure" << endl;
           break;
       default:
-          dbglogfile << "No warning mode" << endl;
+          BOOST_LOG(lg) << "No warning mode" << endl;
           break;
     };
 }
@@ -623,13 +623,13 @@ outback::calcChecksum(const char *packet)
         checksum+= (*ptr++) - '0';
     } while ((ptr - packet) <= 44); // Don't add the checksum itself
 
-    //dbglogfile << "Transmitted checksum for packet is: " << chk << endl;
-    //dbglogfile << "Calculated checksum for packet is: " << checksum << endl;
+    //BOOST_LOG(lg) << "Transmitted checksum for packet is: " << chk << endl;
+    //BOOST_LOG(lg) << "Calculated checksum for packet is: " << checksum << 
endl;
 
     // See if the calculated checksum matches the checksum from the
     // packet checksum field. (the last 3 bytes before the CR terminator)
     if (checksum != chk_field) {
-        dbglogfile << "ERROR: Checksums don't match!" << endl;
+        BOOST_LOG(lg) << "ERROR: Checksums don't match!" << endl;
         return ERROR;
     }
   
@@ -719,7 +719,7 @@ outback::exportMeterData(meter_data_t *data)
 #if defined(HAVE_MARIADB) && defined(HAVE_POSTGRESQL)
         } else {
             if (outdev.main(con, pdb) == ERROR) {
-                dbglogfile << "ERROR: Main Loop exited with an error!" << endl;
+                BOOST_LOG(lg) << "ERROR: Main Loop exited with an error!" << 
endl;
             }
 #endif
         }
diff --git a/devices/ownet.cc b/devices/ownet.cc
index 575ae91..2838e10 100644
--- a/devices/ownet.cc
+++ b/devices/ownet.cc
@@ -20,9 +20,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/make_shared.hpp>
 #include "ownet.h"
-
-//extern LogFile dbglogfile;
-#define dbglogfile std::cerr
+#include "log.h"
 
 // Default host and port for the owserver
 const int OWPORT = 4304;
@@ -33,19 +31,19 @@ Ownet::Ownet(void)
       _scale('F'),
       _owserver(false)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 }
 
 Ownet::Ownet(std::string &host)
     : Ownet()
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     int retries = 2;
     if (host.find(':') == std::string::npos) {
         host += ":" + std::to_string(OWPORT);
     }
-    dbglogfile << "Trying to connect to the owserver on " << host << std::endl;
+    BOOST_LOG(lg) << "Trying to connect to the owserver on " << host;
 
     // OW_init() takes what looks like a standard command line
     std::string argv = "-s " + host;
@@ -54,10 +52,10 @@ Ownet::Ownet(std::string &host)
     // but always does on the second.
     while (retries-- > 0) {
         if (OW_init(argv.c_str()) < 0) {
-            dbglogfile << "WARNING: Couldn't connect to owserver with " << 
argv << std::endl;
+            BOOST_LOG(lg) << "WARNING: Couldn't connect to owserver with " << 
argv;
             //return;
         } else {
-            dbglogfile << "Connected to owserver on host " << host << 
std::endl;
+            BOOST_LOG(lg) << "Connected to owserver on host " << host;
             _owserver = true;
             break;
         }
@@ -98,9 +96,9 @@ Ownet::Ownet(std::string &host)
         }
         std::string dev = *it + "temperature";
         if (OW_present(dev.c_str()) == 0) {
-            dbglogfile << "Temperature sensor found: " << *it << std::endl;
+            BOOST_LOG(lg) << "Temperature sensor found: " << *it;
         } else {
-            dbglogfile << "Temperature sensor not found!" << std::endl;
+            BOOST_LOG(lg) << "Temperature sensor not found!";
         }
         std::lock_guard<std::mutex> guard(_mutex);
         _sensors[*it] = data;
@@ -117,7 +115,7 @@ Ownet::getTemperature(const std::string &device)
     std::string type = getValue(device, "type");
     
     if (family == "10" | family == "28") {
-        // dbglogfile << device << " is a thermometer" << std::endl;
+        // BOOST_LOG(lg) << device << " is a thermometer";
         // boost::shared_ptr<temperature_t> temp = 
boost::make_shared<temperature_t>(1);
         boost::shared_ptr<temperature_t> temp(new temperature_t);
         temp->family = getValue(device, "family");
@@ -132,7 +130,7 @@ Ownet::getTemperature(const std::string &device)
         temp->scale = buffer[0];
         return temp;
     } else {
-        dbglogfile << device << " is not a thermometer" << std::endl;
+        BOOST_LOG(lg) << device << " is not a thermometer";
     }
     boost::shared_ptr<temperature_t> temp;
     return temp;
@@ -141,7 +139,7 @@ Ownet::getTemperature(const std::string &device)
 const std::vector<std::string>
 Ownet::listDevices(std::vector<std::string> &list)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
     
     std::map<std::string, boost::shared_ptr<ownet_t>>::iterator sit;
     for (sit = _sensors.begin(); sit != _sensors.end(); sit++) {
@@ -154,6 +152,8 @@ Ownet::listDevices(std::vector<std::string> &list)
 std::string
 Ownet::getValue(const std::string &device, std::string file)
 {
+//    DEBUGLOG_REPORT_FUNCTION;
+
     char * buf;
     size_t s  = 0;
     
@@ -163,7 +163,7 @@ Ownet::getValue(const std::string &device, std::string file)
     if (ret <= 0) {
         return std::string();
         //} else {
-        //std::cout << ", Got(" << s << "): " <<  buf << std::endl;
+        //std::cout << ", Got(" << s << "): " <<  buf;
     }
     
     std::string value = (buf);
diff --git a/devices/ownet.h b/devices/ownet.h
index f7c708b..49838cc 100644
--- a/devices/ownet.h
+++ b/devices/ownet.h
@@ -28,8 +28,6 @@
 #include "onewire.h"
 #include "log.h"
 
-extern LogFile dbglogfile;
-
 // Default host and port for the owserver
 extern const int OWPORT;
 extern const char *OWHOST;
diff --git a/lib/serial.cc b/devices/serial.cc
similarity index 91%
rename from lib/serial.cc
rename to devices/serial.cc
index 2026510..c76ff1a 100644
--- a/lib/serial.cc
+++ b/devices/serial.cc
@@ -41,8 +41,7 @@
 #include "log.h"
 #include "serial.h"
 
-extern LogFile dbglogfile;
-LogFile seriallogfile; // ("tserial.log")
+static src::logger lg;
 
 // Set the names of the baud rates so we can dump them in a human
 // readable fashion.
@@ -133,7 +132,7 @@ Serial::Open(std::string &filespec)
 {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Opening host device " << filespec << std::endl;
+    BOOST_LOG(lg) << "Opening host device " << filespec << std::endl;
 
     // We don't want to timestamp
     seriallogfile.SetStamp(false);
@@ -168,7 +167,7 @@ Serial::Open(std::string &filespec)
 #if 0
     // set the timeout value for communications
     if (SetTimeout (20, errcond) == ERROR) {
-        dbglogfile << "ERROR: Couldn't set the timeout value";
+        BOOST_LOG(lg) << "ERROR: Couldn't set the timeout value";
         return ERROR;
     }
     DumpTtyState();
@@ -183,7 +182,7 @@ Serial::Close(void)
 {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << std::endl << "Closing host device" << std::endl;
+    BOOST_LOG(lg) << std::endl << "Closing host device" << std::endl;
     seriallogfile << std::endl << "Closing host device" << std::endl;
 
     tcsetattr(_uartfd, TCSANOW, &origtty);
@@ -228,7 +227,7 @@ Serial::Read(char *buf, int nbytes)
             FD_SET(_uartfd, &fdset);
       
             sret = select(_uartfd+1, &fdset, NULL, NULL, &timeout);
-            dbglogfile << "select returned " << sret
+            BOOST_LOG(lg) << "select returned " << sret
                        << " for file descriptor  " << _uartfd << std::endl;
 #if 1
             if (sret == 0) {
@@ -245,13 +244,13 @@ Serial::Read(char *buf, int nbytes)
             memset(tmpbuf, 0, nbytes+1);
             memset(buf, 0, nbytes);
             ret = ::read (_uartfd, tmpbuf, nbytes);
-            dbglogfile << "read returned " << ret << " for file descriptor  " 
<< _uartfd << std::endl;
+            BOOST_LOG(lg) << "read returned " << ret << " for file descriptor  
" << _uartfd << std::endl;
             if (ret == 0) {
                 continue;
             }
       
             if (ret > 0) {
-                dbglogfile << "Read " << ret << " bytes" << std::endl;
+                BOOST_LOG(lg) << "Read " << ret << " bytes" << std::endl;
                 //if ((line.find('\n', 0) == string::npos) && (ret > 0)) 
                 // Filter out the control characters that appear on the
                 // end of the line
@@ -263,7 +262,7 @@ Serial::Read(char *buf, int nbytes)
                         data += tmpbuf[i];
                     }
                 } // end of for loop
-                // dbglogfile << "Reading more data, data left before is \"" 
<< tmpbuf << "\"" << std::endl;
+                // BOOST_LOG(lg) << "Reading more data, data left before is 
\"" << tmpbuf << "\"" << std::endl;
             }
       
             //if (ret < 0)
@@ -291,12 +290,12 @@ Serial::Read(char *buf, int nbytes)
         
     //if ((ret == 1) && (ret == 0xa)) {
     if (ret == 1) {
-        dbglogfile << "Read CR " << std:;endl;
+        BOOST_LOG(lg) << "Read CR " << std:;endl;
         //ret = ::read (_uartfd, buf, 36);
     }
         
     if (ret > 0) {
-        dbglogfile << "Read " << ret << " bytes" << std::endl;
+        BOOST_LOG(lg) << "Read " << ret << " bytes" << std::endl;
         for (i=0; i< nbytes; i++){
 #if 0
             if (buf[i] == 0xa) {
@@ -305,7 +304,7 @@ Serial::Read(char *buf, int nbytes)
             }
 #endif
             if ((buf[i] > ' ') && (buf[i] < 'z')) {
-                dbglogfile << "Copying character: " << i << std::endl;
+                BOOST_LOG(lg) << "Copying character: " << i << std::endl;
                 *bufptr++ = buf[i];
             } else {
                 buf[i] = ' ';
@@ -319,7 +318,7 @@ Serial::Read(char *buf, int nbytes)
 }
 
 if ((sret == 0) && (ret <= 0)) {
-    dbglogfile << "WARNING: Too many retries." << std::endl;
+    BOOST_LOG(lg) << "WARNING: Too many retries." << std::endl;
 }
 
 //    seriallogfile.Write((const char *)buf, ret);
@@ -378,7 +377,7 @@ Serial::SetBaud (int baudcode)
 #endif
     int ret = tcsetattr(_uartfd, TCSANOW, &ctty);
     if (ret == 0) {
-        dbglogfile << __PRETTY_FUNCTION__ << " worked" << std::endl;
+        BOOST_LOG(lg) << __PRETTY_FUNCTION__ << " worked" << std::endl;
         return SUCCESS;
     }
   
@@ -388,10 +387,10 @@ Serial::SetBaud (int baudcode)
     //int ret = tcsetattr(_uartfd, TCSADRAIN, &currenttty);
     ibaud = cfgetispeed(&currenttty);
     obaud = cfgetospeed(&currenttty);
-    dbglogfile << "Input baud is now set to " << serial_speeds[ibaud] << 
std::endl;
-    dbglogfile << "Output baud is now set to " << serial_speeds[obaud] << 
std::endl;
+    BOOST_LOG(lg) << "Input baud is now set to " << serial_speeds[ibaud] << 
std::endl;
+    BOOST_LOG(lg) << "Output baud is now set to " << serial_speeds[obaud] << 
std::endl;
 
-    dbglogfile << __PRETTY_FUNCTION__ << " failed" << std::endl;
+    BOOST_LOG(lg) << __PRETTY_FUNCTION__ << " failed" << std::endl;
     return ERROR;
 }
 
@@ -494,10 +493,10 @@ Serial::DumpTtyState (void)
     int ibaud, obaud;
 
     ibaud = cfgetispeed(&currenttty);
-    dbglogfile << "Input baud rate is " << serial_speeds[ibaud] << std::endl;
+    BOOST_LOG(lg) << "Input baud rate is " << serial_speeds[ibaud] << 
std::endl;
 
     obaud = cfgetospeed(&currenttty);
-    dbglogfile << "Output baud rate is " << serial_speeds[obaud] << std::endl;
+    BOOST_LOG(lg) << "Output baud rate is " << serial_speeds[obaud] << 
std::endl;
   
 }
 
diff --git a/lib/serial.h b/devices/serial.h
similarity index 98%
rename from lib/serial.h
rename to devices/serial.h
index 4882588..f50af22 100644
--- a/lib/serial.h
+++ b/devices/serial.h
@@ -34,9 +34,6 @@
 
 #include <termios.h>
 
-// Project include files
-#include "err.h"
-
 //#define DEFAULT_UART "/dev/pts/12";
 #define DEFAULT_UART "/dev/ttyS0";
 
diff --git a/devices/xanbus.cc b/devices/xanbus.cc
index e519cd1..c86dc1a 100644
--- a/devices/xanbus.cc
+++ b/devices/xanbus.cc
@@ -154,7 +154,7 @@ XanbusUI::ReadSerial(void)
   
     while (retries--) {
         if (ret = Read((char *)&buffy, 99) < 0) {
-            //dbglogfile << "FIXME: " << retries << "\t" << buffy << endl;
+            //BOOST_LOG(lg) << "FIXME: " << retries << "\t" << buffy << endl;
             //ret = Read((char *)&buffy, 100);
             continue;
         } else {
@@ -166,7 +166,7 @@ XanbusUI::ReadSerial(void)
 #endif
   
     if (ret > 0) {
-        //dbglogfile << "FIXME3: Read " << ret << " bytes: " << buffy << "\t" 
<< buffy << endl;
+        //BOOST_LOG(lg) << "FIXME3: Read " << ret << " bytes: " << buffy << 
"\t" << buffy << endl;
         menudisp = buffy;
     } else {
         menudisp.erase();
@@ -179,7 +179,7 @@ string
 XanbusUI::GetLabel() {
     //DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "menuheading: " << menuheading << " menuitem:" << menuitem 
<< endl;
+    BOOST_LOG(lg) << "menuheading: " << menuheading << " menuitem:" << 
menuitem << endl;
   
     MenuItem ti = GetItem(menuheading, menuitem);
   
@@ -195,7 +195,7 @@ XanbusUI::WriteSerial(const char *buf, int nbytes)
     memset(buffy, 0, 100);
   
     ret = Write(buf, nbytes);
-    //dbglogfile << "FIXME" << buffy << endl;
+    //BOOST_LOG(lg) << "FIXME" << buffy << endl;
     ret = Read(buffy, nbytes);
   
     menudisp = buffy;
@@ -211,7 +211,7 @@ XanbusUI::SelectInverter(int x)
 
     Write((char *)&x, 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -227,7 +227,7 @@ XanbusUI::MenuHeadingMinus(void)
     Write("L", 1);
     //Read((char *)&buffy, 100);
     menudisp = ReadSerial();
-    //dbglogfile << "FIXME" << menudisp << endl;
+    //BOOST_LOG(lg) << "FIXME" << menudisp << endl;
 
     //cerr << "FIXMEh-: \"" << menudisp  << "\"" << endl;
     //cerr << "FIXMEh-: \"" << GetLabel() << "\"" << endl;
@@ -238,9 +238,9 @@ XanbusUI::MenuHeadingMinus(void)
     menuitem = 0;
 
     if (menudisp.find(GetLabel()) == string::npos) {
-        dbglogfile << "Heading Minus didn't Match!!" << menuheading << endl;  
+        BOOST_LOG(lg) << "Heading Minus didn't Match!!" << menuheading << 
endl;  
     } else {
-        dbglogfile << "Heading Minus Matched!!" << endl;
+        BOOST_LOG(lg) << "Heading Minus Matched!!" << endl;
     }
 
 
@@ -261,7 +261,7 @@ XanbusUI::MenuHeadingPlus(void)
     menudisp = ReadSerial();
     //mi = GetItem();
 
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
 
     menuheading++;
     menuitem = 0;
@@ -270,9 +270,9 @@ XanbusUI::MenuHeadingPlus(void)
     //cerr << "FIXMEh+: \"" << GetLabel() << "\"" << endl;
   
     if (menudisp.find(GetLabel()) == string::npos) {
-        dbglogfile << "Heading Plus didn't Match!!" << endl;  
+        BOOST_LOG(lg) << "Heading Plus didn't Match!!" << endl;  
     } else {
-        dbglogfile << "Heading Plus Matched!!" << endl;
+        BOOST_LOG(lg) << "Heading Plus Matched!!" << endl;
     }
 
 
@@ -294,7 +294,7 @@ XanbusUI::MenuItemMinus(void)
     //Write("D", 1);
     //Read((char *)&buffy, 100);
     //menudisp = ReadSerial();
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
 
     menuitem++;
 
@@ -309,9 +309,9 @@ XanbusUI::MenuItemMinus(void)
         label = GetLabel();
         if (label.size()) {
             if (menudisp.find(label) == string::npos) {
-                dbglogfile << "Item Minus didn't Match!!" << endl;
+                BOOST_LOG(lg) << "Item Minus didn't Match!!" << endl;
             } else {
-                dbglogfile << "Item Minus Matched!!" << endl;
+                BOOST_LOG(lg) << "Item Minus Matched!!" << endl;
                 break;
             }
         }
@@ -332,13 +332,13 @@ XanbusUI::MenuItemPlus(void)
     //Write("U", 1);
     //Read((char *)&buffy, 100);
     //menudisp = ReadSerial();
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
     //menudisp = buffy;
     if (menuitem > 1)
         menuitem--;
 
     //  if (strcmp(label.c_str(), buffy) == 0)
-    //    dbglogfile << "AAAAHHHHHHH" << endl;
+    //    BOOST_LOG(lg) << "AAAAHHHHHHH" << endl;
   
     while (retries--) {
         Write("U", 1);
@@ -349,15 +349,15 @@ XanbusUI::MenuItemPlus(void)
         //cerr << "FIXMEi+: \"" << GetLabel() << "\"" << endl;
 
         if (menudisp.find(GetLabel()) == string::npos) {
-            dbglogfile << "Item Plus didn't Match!!" << endl;
+            BOOST_LOG(lg) << "Item Plus didn't Match!!" << endl;
         } else {
-            dbglogfile << "Item Plus Matched!!" << endl;
+            BOOST_LOG(lg) << "Item Plus Matched!!" << endl;
             break;
         }
     }
 
     //  if (menudisp != label)
-    //  dbglogfile << "FIXME: Wrong Item " << menuheading << ":" << menuitem 
<< menudisp << "\t" << label << endl;
+    //  BOOST_LOG(lg) << "FIXME: Wrong Item " << menuheading << ":" << 
menuitem << menudisp << "\t" << label << endl;
     
     return menudisp;
 }
@@ -370,7 +370,7 @@ XanbusUI::SetPointMinus(void)
   
     Write("-", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -384,7 +384,7 @@ XanbusUI::SetPointPlus(void)
   
     Write("+", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -398,7 +398,7 @@ XanbusUI::Inverter(void)
   
     Write("|", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -412,7 +412,7 @@ XanbusUI::Generator(void)
   
     Write("G", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -426,7 +426,7 @@ XanbusUI::SetupMenu(void)
   
     Write("\003", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menuheading = 8;
     menuitem = 0;
@@ -443,7 +443,7 @@ XanbusUI::LedStatus(void)
   
     Write("?", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;  
@@ -457,7 +457,7 @@ XanbusUI::Version(void)
   
     Write("V", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -471,7 +471,7 @@ XanbusUI::SetTerminalMode(void)
   
     Write("T", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -517,7 +517,7 @@ XanbusUI::GotoMenuStart(void)
   
     menuheading = 1;
     menuitem = 0;
-    dbglogfile << "At Start Of Menu" << endl;
+    BOOST_LOG(lg) << "At Start Of Menu" << endl;
   
     return SUCCESS;
 }
@@ -688,7 +688,7 @@ XanbusUI::GotoMenuItem(int mh, int mi)
     }
 
     if (menudisp.find(item.GetLabel()) != string::npos) {
-        dbglogfile << "Didn't Match!!" << endl;  
+        BOOST_LOG(lg) << "Didn't Match!!" << endl;  
     }
 
     //menudisp = CleanUpData(tmpstr);
@@ -749,38 +749,38 @@ XanbusUI::PollMeters(int loops)
                     //downdata->
                 }
                 if (label.substr(0, 4) == "Load") {
-                    dbglogfile << "Matched label going down " << label;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->ac_load_amps = intval;
                 }
                 if (label.substr(8, 6) == "actual") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->battery_volts = fltval;
                 }
                 if (label.substr(8, 8) == "TempComp") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->tempcomp_volts = fltval;
                 }
                 if (label.substr(0, 8) == "Inverter") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->ac_volts_out = intval;
                 }
                 if (label.substr(0, 4) == "Grid") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->ac1_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Generator") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->ac2_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Read Freq") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->hertz = intval;
                 }
             }
@@ -817,41 +817,41 @@ XanbusUI::PollMeters(int loops)
                     //updata->
                 }
                 if (label.substr(0, 4) == "Load ") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     updata->ac_load_amps = intval;
                 }
                 if (label.substr(8, 6) == "actual") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->battery_volts = fltval;
                 }
                 if (label.substr(8, 8) == "TempComp") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->tempcomp_volts = fltval;
                 }
                 if (label.substr(0, 8) == "Inverter") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     updata->ac_volts_out = intval;
                 }
                 if (label.substr(0, 4) == "Grid") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->ac1_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Generator") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->ac2_volts_in = fltval;
                 }
                 // Since this is the last and first reading, it doesn't really
                 // have time to change.
                 updata->hertz = downdata->hertz;
 //         if (label.substr(0, 9) == "Read Freq") {
-//           dbglogfile << "Matched label going up " << label << endl;
-//           dbglogfile << " value is: " << intval << endl;
+//           BOOST_LOG(lg) << "Matched label going up " << label << endl;
+//           BOOST_LOG(lg) << " value is: " << intval << endl;
 //           updata->hertz = intval;
 //         }
             } // end of if str
@@ -1284,7 +1284,7 @@ XanbusUI::Dump (void)
     vector< vector< MenuItem > >::iterator mh;
     vector< MenuItem >::iterator it;
 
-    dbglogfile << "There are " << (int)_items.size() << " menu _items" << endl;
+    BOOST_LOG(lg) << "There are " << (int)_items.size() << " menu _items" << 
endl;
 
     for (mh = _items.begin(); mh != _items.end(); ++mh) {
         for (it = mh->begin(); it != mh->end(); ++it) {
@@ -1328,10 +1328,10 @@ XanbusUI::Match(string &str)
     for (mh = _items.begin(); mh != _items.end(); ++mh) {
         arg = *mh;
         for (it = arg.begin(); it != arg.end(); ++it) {
-            dbglogfile << "Matching \"" << it->GetAlias() << "\""
+            BOOST_LOG(lg) << "Matching \"" << it->GetAlias() << "\""
                        << " against the argument \"" << str << "\"" << endl;
             if (it->GetAlias() == str){
-                dbglogfile << "Matched " << it->GetLabel() << " !" << endl;
+                BOOST_LOG(lg) << "Matched " << it->GetLabel() << " !" << endl;
                 return *it;
             }
         }
@@ -1474,28 +1474,28 @@ XanbusUI::xantrex_main(Console &con);
                   case MenuItem::MENUITEM:
                   case MenuItem::BOOL:
                       if (ui.GetBoolValue() == false)
-                          dbglogfile << "\tBoolean value is: " << "OFF" ;
+                          BOOST_LOG(lg) << "\tBoolean value is: " << "OFF" ;
                       else
-                          dbglogfile << "\tBoolean value is: " << "ON" ;      
-                      dbglogfile << endl;
+                          BOOST_LOG(lg) << "\tBoolean value is: " << "ON" ;    
  
+                      BOOST_LOG(lg) << endl;
                       break;
                   case MenuItem::INT:
-                      dbglogfile << "\tInteger value is: " << value.intval << 
endl;
+                      BOOST_LOG(lg) << "\tInteger value is: " << value.intval 
<< endl;
                       break;
                   case MenuItem::FLOAT:
                       cerr << "\tFIXME: Float value is: " << value.floatval << 
endl;
                       break;
                   case MenuItem::TIME:
-                      dbglogfile << "\tTime value is: " << value.timeval << 
endl;
+                      BOOST_LOG(lg) << "\tTime value is: " << value.timeval << 
endl;
                       break;
                   case MenuItem::EOL:
                   case MenuItem::CLOCK:
                   case MenuItem::ENUM:
                   case MenuItem::DATE:
-                      dbglogfile << "\tFIXME: unsupported type! " << 
value.intval << endl;
+                      BOOST_LOG(lg) << "\tFIXME: unsupported type! " << 
value.intval << endl;
                       break;
                   default:
-                      dbglogfile << "Data Type out of range";
+                      BOOST_LOG(lg) << "Data Type out of range";
                       break;
                 };
 #endif
@@ -1517,7 +1517,7 @@ XanbusUI::xantrex_main(Console &con);
         //    ui.Read((char *)&buffy, 100);
         cerr << "Inverter returned: " << str << endl;
 
-        //      dbglogfile << "BREAK HERE" << endl;
+        //      BOOST_LOG(lg) << "BREAK HERE" << endl;
       
         switch (ti.GetType()) {
           case MenuItem::BOOL:
diff --git a/devices/xantrex-trace.cc b/devices/xantrex-trace.cc
index 5511647..f1670cc 100644
--- a/devices/xantrex-trace.cc
+++ b/devices/xantrex-trace.cc
@@ -58,7 +58,7 @@ XantrexUI::ReadSerial(void)
   
     while (retries--) {
         if (ret = Read((char *)&buffy, 99) < 0) {
-            //dbglogfile << "FIXME: " << retries << "\t" << buffy << endl;
+            //BOOST_LOG(lg) << "FIXME: " << retries << "\t" << buffy << endl;
             //ret = Read((char *)&buffy, 100);
             continue;
         } else {
@@ -70,7 +70,7 @@ XantrexUI::ReadSerial(void)
 #endif
   
     if (ret > 0) {
-        //dbglogfile << "FIXME3: Read " << ret << " bytes: " << buffy << "\t" 
<< buffy << endl;
+        //BOOST_LOG(lg) << "FIXME3: Read " << ret << " bytes: " << buffy << 
"\t" << buffy << endl;
         menudisp = buffy;
     } else {
         menudisp.erase();
@@ -83,7 +83,7 @@ string
 XantrexUI::GetLabel() {
     //DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "menuheading: " << menuheading << " menuitem:" << menuitem 
<< endl;
+    BOOST_LOG(lg) << "menuheading: " << menuheading << " menuitem:" << 
menuitem << endl;
   
     MenuItem ti = GetItem(menuheading, menuitem);
   
@@ -99,7 +99,7 @@ XantrexUI::WriteSerial(const char *buf, int nbytes)
     memset(buffy, 0, 100);
   
     ret = Write(buf, nbytes);
-    //dbglogfile << "FIXME" << buffy << endl;
+    //BOOST_LOG(lg) << "FIXME" << buffy << endl;
     ret = Read(buffy, nbytes);
   
     menudisp = buffy;
@@ -115,7 +115,7 @@ XantrexUI::SelectInverter(int x)
 
     Write((char *)&x, 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -131,7 +131,7 @@ XantrexUI::MenuHeadingMinus(void)
     Write("L", 1);
     //Read((char *)&buffy, 100);
     menudisp = ReadSerial();
-    //dbglogfile << "FIXME" << menudisp << endl;
+    //BOOST_LOG(lg) << "FIXME" << menudisp << endl;
 
     //cerr << "FIXMEh-: \"" << menudisp  << "\"" << endl;
     //cerr << "FIXMEh-: \"" << GetLabel() << "\"" << endl;
@@ -142,9 +142,9 @@ XantrexUI::MenuHeadingMinus(void)
     menuitem = 0;
 
     if (menudisp.find(GetLabel()) == string::npos) {
-        dbglogfile << "Heading Minus didn't Match!!" << menuheading << endl;  
+        BOOST_LOG(lg) << "Heading Minus didn't Match!!" << menuheading << 
endl;  
     } else {
-        dbglogfile << "Heading Minus Matched!!" << endl;
+        BOOST_LOG(lg) << "Heading Minus Matched!!" << endl;
     }
 
 
@@ -165,7 +165,7 @@ XantrexUI::MenuHeadingPlus(void)
     menudisp = ReadSerial();
     //mi = GetItem();
 
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
 
     menuheading++;
     menuitem = 0;
@@ -174,9 +174,9 @@ XantrexUI::MenuHeadingPlus(void)
     //cerr << "FIXMEh+: \"" << GetLabel() << "\"" << endl;
   
     if (menudisp.find(GetLabel()) == string::npos) {
-        dbglogfile << "Heading Plus didn't Match!!" << endl;  
+        BOOST_LOG(lg) << "Heading Plus didn't Match!!" << endl;  
     } else {
-        dbglogfile << "Heading Plus Matched!!" << endl;
+        BOOST_LOG(lg) << "Heading Plus Matched!!" << endl;
     }
 
 
@@ -198,7 +198,7 @@ XantrexUI::MenuItemMinus(void)
     //Write("D", 1);
     //Read((char *)&buffy, 100);
     //menudisp = ReadSerial();
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
 
     menuitem++;
 
@@ -213,9 +213,9 @@ XantrexUI::MenuItemMinus(void)
         label = GetLabel();
         if (label.size()) {
             if (menudisp.find(label) == string::npos) {
-                dbglogfile << "Item Minus didn't Match!!" << endl;
+                BOOST_LOG(lg) << "Item Minus didn't Match!!" << endl;
             } else {
-                dbglogfile << "Item Minus Matched!!" << endl;
+                BOOST_LOG(lg) << "Item Minus Matched!!" << endl;
                 break;
             }
         }
@@ -236,13 +236,13 @@ XantrexUI::MenuItemPlus(void)
     //Write("U", 1);
     //Read((char *)&buffy, 100);
     //menudisp = ReadSerial();
-    //dbglogfile << menudisp << endl;
+    //BOOST_LOG(lg) << menudisp << endl;
     //menudisp = buffy;
     if (menuitem > 1)
         menuitem--;
 
     //  if (strcmp(label.c_str(), buffy) == 0)
-    //    dbglogfile << "AAAAHHHHHHH" << endl;
+    //    BOOST_LOG(lg) << "AAAAHHHHHHH" << endl;
   
     while (retries--) {
         Write("U", 1);
@@ -253,15 +253,15 @@ XantrexUI::MenuItemPlus(void)
         //cerr << "FIXMEi+: \"" << GetLabel() << "\"" << endl;
 
         if (menudisp.find(GetLabel()) == string::npos) {
-            dbglogfile << "Item Plus didn't Match!!" << endl;
+            BOOST_LOG(lg) << "Item Plus didn't Match!!" << endl;
         } else {
-            dbglogfile << "Item Plus Matched!!" << endl;
+            BOOST_LOG(lg) << "Item Plus Matched!!" << endl;
             break;
         }
     }
 
     //  if (menudisp != label)
-    //  dbglogfile << "FIXME: Wrong Item " << menuheading << ":" << menuitem 
<< menudisp << "\t" << label << endl;
+    //  BOOST_LOG(lg) << "FIXME: Wrong Item " << menuheading << ":" << 
menuitem << menudisp << "\t" << label << endl;
     
     return menudisp;
 }
@@ -274,7 +274,7 @@ XantrexUI::SetPointMinus(void)
   
     Write("-", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -288,7 +288,7 @@ XantrexUI::SetPointPlus(void)
   
     Write("+", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -302,7 +302,7 @@ XantrexUI::Inverter(void)
   
     Write("|", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -316,7 +316,7 @@ XantrexUI::Generator(void)
   
     Write("G", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -330,7 +330,7 @@ XantrexUI::SetupMenu(void)
   
     Write("\003", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menuheading = 8;
     menuitem = 0;
@@ -347,7 +347,7 @@ XantrexUI::LedStatus(void)
   
     Write("?", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;  
@@ -361,7 +361,7 @@ XantrexUI::Version(void)
   
     Write("V", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -375,7 +375,7 @@ XantrexUI::SetTerminalMode(void)
   
     Write("T", 1);
     Read((char *)&buffy, 100);
-    dbglogfile << buffy << endl;
+    BOOST_LOG(lg) << buffy << endl;
 
     menudisp = buffy;
     return menudisp;
@@ -421,7 +421,7 @@ XantrexUI::GotoMenuStart(void)
   
     menuheading = 1;
     menuitem = 0;
-    dbglogfile << "At Start Of Menu" << endl;
+    BOOST_LOG(lg) << "At Start Of Menu" << endl;
   
     return SUCCESS;
 }
@@ -592,7 +592,7 @@ XantrexUI::GotoMenuItem(int mh, int mi)
     }
 
     if (menudisp.find(item.GetLabel()) != string::npos) {
-        dbglogfile << "Didn't Match!!" << endl;  
+        BOOST_LOG(lg) << "Didn't Match!!" << endl;  
     }
 
     //menudisp = CleanUpData(tmpstr);
@@ -653,38 +653,38 @@ XantrexUI::PollMeters(int loops)
                     //downdata->
                 }
                 if (label.substr(0, 4) == "Load") {
-                    dbglogfile << "Matched label going down " << label;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->ac_load_amps = intval;
                 }
                 if (label.substr(8, 6) == "actual") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->battery_volts = fltval;
                 }
                 if (label.substr(8, 8) == "TempComp") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->tempcomp_volts = fltval;
                 }
                 if (label.substr(0, 8) == "Inverter") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->ac_volts_out = intval;
                 }
                 if (label.substr(0, 4) == "Grid") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->ac1_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Generator") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     downdata->ac2_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Read Freq") {
-                    dbglogfile << "Matched label going down " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going down " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     downdata->hertz = intval;
                 }
             }
@@ -721,41 +721,41 @@ XantrexUI::PollMeters(int loops)
                     //updata->
                 }
                 if (label.substr(0, 4) == "Load ") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     updata->ac_load_amps = intval;
                 }
                 if (label.substr(8, 6) == "actual") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->battery_volts = fltval;
                 }
                 if (label.substr(8, 8) == "TempComp") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->tempcomp_volts = fltval;
                 }
                 if (label.substr(0, 8) == "Inverter") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << intval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << intval << endl;
                     updata->ac_volts_out = intval;
                 }
                 if (label.substr(0, 4) == "Grid") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->ac1_volts_in = fltval;
                 }
                 if (label.substr(0, 9) == "Generator") {
-                    dbglogfile << "Matched label going up " << label << endl;
-                    dbglogfile << " value is: " << fltval << endl;
+                    BOOST_LOG(lg) << "Matched label going up " << label << 
endl;
+                    BOOST_LOG(lg) << " value is: " << fltval << endl;
                     updata->ac2_volts_in = fltval;
                 }
                 // Since this is the last and first reading, it doesn't really
                 // have time to change.
                 updata->hertz = downdata->hertz;
 //         if (label.substr(0, 9) == "Read Freq") {
-//           dbglogfile << "Matched label going up " << label << endl;
-//           dbglogfile << " value is: " << intval << endl;
+//           BOOST_LOG(lg) << "Matched label going up " << label << endl;
+//           BOOST_LOG(lg) << " value is: " << intval << endl;
 //           updata->hertz = intval;
 //         }
             } // end of if str
@@ -1188,7 +1188,7 @@ XantrexUI::Dump (void)
     vector< vector< MenuItem > >::iterator mh;
     vector< MenuItem >::iterator it;
 
-    dbglogfile << "There are " << (int)_items.size() << " menu _items" << endl;
+    BOOST_LOG(lg) << "There are " << (int)_items.size() << " menu _items" << 
endl;
 
     for (mh = _items.begin(); mh != _items.end(); ++mh) {
         for (it = mh->begin(); it != mh->end(); ++it) {
@@ -1232,10 +1232,10 @@ XantrexUI::Match(string &str)
     for (mh = _items.begin(); mh != _items.end(); ++mh) {
         arg = *mh;
         for (it = arg.begin(); it != arg.end(); ++it) {
-            dbglogfile << "Matching \"" << it->GetAlias() << "\""
+            BOOST_LOG(lg) << "Matching \"" << it->GetAlias() << "\""
                        << " against the argument \"" << str << "\"" << endl;
             if (it->GetAlias() == str){
-                dbglogfile << "Matched " << it->GetLabel() << " !" << endl;
+                BOOST_LOG(lg) << "Matched " << it->GetLabel() << " !" << endl;
                 return *it;
             }
         }
@@ -1378,28 +1378,28 @@ XantrexUI::xantrex_main(Console &con);
                   case MenuItem::MENUITEM:
                   case MenuItem::BOOL:
                       if (ui.GetBoolValue() == false)
-                          dbglogfile << "\tBoolean value is: " << "OFF" ;
+                          BOOST_LOG(lg) << "\tBoolean value is: " << "OFF" ;
                       else
-                          dbglogfile << "\tBoolean value is: " << "ON" ;      
-                      dbglogfile << endl;
+                          BOOST_LOG(lg) << "\tBoolean value is: " << "ON" ;    
  
+                      BOOST_LOG(lg) << endl;
                       break;
                   case MenuItem::INT:
-                      dbglogfile << "\tInteger value is: " << value.intval << 
endl;
+                      BOOST_LOG(lg) << "\tInteger value is: " << value.intval 
<< endl;
                       break;
                   case MenuItem::FLOAT:
                       cerr << "\tFIXME: Float value is: " << value.floatval << 
endl;
                       break;
                   case MenuItem::TIME:
-                      dbglogfile << "\tTime value is: " << value.timeval << 
endl;
+                      BOOST_LOG(lg) << "\tTime value is: " << value.timeval << 
endl;
                       break;
                   case MenuItem::EOL:
                   case MenuItem::CLOCK:
                   case MenuItem::ENUM:
                   case MenuItem::DATE:
-                      dbglogfile << "\tFIXME: unsupported type! " << 
value.intval << endl;
+                      BOOST_LOG(lg) << "\tFIXME: unsupported type! " << 
value.intval << endl;
                       break;
                   default:
-                      dbglogfile << "Data Type out of range";
+                      BOOST_LOG(lg) << "Data Type out of range";
                       break;
                 };
 #endif
@@ -1421,7 +1421,7 @@ XantrexUI::xantrex_main(Console &con);
         //    ui.Read((char *)&buffy, 100);
         cerr << "Inverter returned: " << str << endl;
 
-        //      dbglogfile << "BREAK HERE" << endl;
+        //      BOOST_LOG(lg) << "BREAK HERE" << endl;
       
         switch (ti.GetType()) {
           case MenuItem::BOOL:
diff --git a/doc/C/Makefile.am b/doc/C/Makefile.am
index f4f239c..6a346bf 100644
--- a/doc/C/Makefile.am
+++ b/doc/C/Makefile.am
@@ -1,7 +1,8 @@
 ## Process this file with automake to produce Makefile.in
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004  Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005-2018.
+#
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -43,7 +44,7 @@ alldocs: html pdf man
 html: powerguru.html
 pdf:  powerguru.pdf
 man:  pgd.1
-powerguru.pdf powerguru.html: powerguru.xml outback.xml xantrex.xml
+powerguru.pdf powerguru.html: powergdb2x_texixml powerguru.txmluru.xml 
outback.xml xantrex.xml
 
 .xml.html:
        @echo "Making HTML from XML source..."
diff --git a/doc/C/powerguru.xml b/doc/C/powerguru.xml
index 6a044e3..ed0a3f7 100644
--- a/doc/C/powerguru.xml
+++ b/doc/C/powerguru.xml
@@ -1,358 +1,78 @@
-<?xml version="1.0"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
-    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
-  <!ENTITY legal SYSTEM "legal.xml">
-  <!ENTITY appversion "0.2">
-  <!ENTITY manrevision "0.2">
-  <!ENTITY date "August 2005">
-  <!ENTITY app "<application>PowerGuru</application>">
-  <!ENTITY appname "Power Guru">
-  <!ENTITY version "2.0">
-  <!ENTITY xantrexdoc SYSTEM "xantrex.xml"> 
-  <!ENTITY outbackdoc SYSTEM "outback.xml"> 
-  <!ENTITY man SYSTEM "man.xml"> 
- ]
->
-
- <!-- =============Document Header ============================= -->
- <article id="index" lang="en">
-<!-- please do not change the id; for translations, change lang to -->
-<!-- appropriate code -->
-   <articleinfo>
-     <title>&app; Manual V&manrevision;</title>
-     <copyright>
-       <year>2005</year>
-       <holder>Rob Savoye</holder>
-     </copyright>
-<!-- translators: uncomment this:
-
-  <copyright>
-   <year>2005</year>
-   <holder>ME-THE-TRANSLATOR (Latin translation)</holder>
-  </copyright>
-
-   -->
-<!-- An address can be added to the publisher information.  If a role is 
-     not specified, the publisher/author is the same for all versions of the 
-     document.  -->
-    <publisher> 
-      <publishername> GNOME Documentation Project </publishername> 
-    </publisher> 
-
-<!-- 
-      Copyright (c)  2005, Free Software Foundation, Inc.
-      Permission is granted to copy, distribute and/or modify this document
-      under the terms of the GNU Free Documentation License, Version 1.2
-      or any later version published by the Free Software Foundation;
-      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
-      Texts.  A copy of the license is included in the section entitled "GNU
-      Free Documentation License".
--->
-
-   &legal;
-   <!-- This file  contains link to license for the documentation (GNU FDL), 
and 
-        other legal stuff such as "NO WARRANTY" statement. Please do not 
change 
-       any of this. -->
-
-    <authorgroup> 
-      <author> 
-       <firstname>Rob</firstname> 
-       <surname>Savoye</surname> 
-       <affiliation> 
-         <address>
-           <email>address@hidden</email>
-         </address> 
-       </affiliation> 
-      </author> 
-<!-- This is appropriate place for other contributors: translators,
-      maintainers,  etc. Commented out by default.
-       <othercredit role="translator">
-       <firstname>Latin</firstname> 
-       <surname>Translator 1</surname> 
-       <affiliation> 
-         <orgname>Latin Translation Team</orgname> 
-         <address> <email>address@hidden</email> </address> 
-       </affiliation>
-       <contrib>Latin translation</contrib>
-      </othercredit>
--->
-    </authorgroup>
-
-    <revhistory>
-      <revision> 
-       <revnumber>&appname; Manual V&manrevision;</revnumber> 
-       <date>&date;</date> 
-       <revdescription> 
-         <para role="author">Rob Savoye
-           <email>address@hidden</email>
-         </para>
-         <para role="publisher">GNOME Documentation Project</para>
-       </revdescription> 
-      </revision> 
-    </revhistory> 
-
-    <releaseinfo>This manual describes version &appversion; of &appname;.
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd";>
+<article lang="en">
+  <articleinfo>
+    <title>PowerGuru Manual V0.2</title>
+    <subtitle/>
+    <edition/>
+    <releaseinfo>This manual describes version  of .
     </releaseinfo>
-   </articleinfo>
-
-  <indexterm zone="index"> 
-    <primary>PowerGuru</primary> 
-  </indexterm>
-
-<!-- ============= Document Body ============================= -->
-<!-- ============= Introduction ============================== -->
-  <sect1 id="intro"> <title>Introduction</title>
-    <para>This is power monitoring system for Xantrex (was Trace)
-     and Outback Power Systems products.
-    </para>
-    <sect2 id="betterintro">
-      <title>What is &appname; ?</title>
-      <para>&appname; is a tool for remotely controlling
-      <ulink type="http" url="http://www.xantrex.com";>Xantrex</ulink>
-      and <ulink type="http" url="http://www.outbackpower.com";>Outback
-      Power Systems</ulink> products. In my case, an old Trace 4024 and
-      an Outback MX-60.
-
-       <mediaobject>
-         <imageobject>
-           <imagedata fileref="images/domes.png"/>
-         </imageobject>
-       </mediaobject>  
-      </para>
-
-      <para>This all started when I bought a fixer upper, off-grid
-       house... Like many projects, this one seems to have fallen
-       into my lap, more than it was a concious idea. Over time, the
-       concept has evolved into an actual product in development.
-       That project, <ulink type="http" url="http://www.senecass.com/abelmon";>
-       AbelMon</ulink>, is a much larger project, and this application
-       <application>&appname;</application>, is part of that project
-       spun off into a standalone application.</para>
-
-      <para>There are other similar products, but for WinDoze are
-        <ulink type="http" url="http://www.righthandeng.com";>Right
-        Hand Engineer's Winverter</ulink> or <ulink type="http"
-        url="http://www.mauisolarsoftware.com";> Maui Solar Software's
-        TraceTools</ulink>.</para>
-
-    </sect2>    
+    <author>
+      <surname>Savoye</surname>
+      <firstname>Rob</firstname>
+      <affiliation>
+        <address>
+           address@hidden
+         </address>
+      </affiliation>
+    </author>
+    <copyright/>
+  </articleinfo>
+  <sect1>
+    <title>Introduction</title>
+    <para>This is power monitoring system for Xantrex (was Trace) and Outback 
Power Systems products. </para>
+    <sect2>
+      <title>What is Power Guru ?</title>
+      <para>is a tool for remotely controlling <ulink 
url="http://www.xantrex.com/";>Xantrex</ulink> and <ulink 
url="http://www.outbackpower.com/";>Outback Power Systems</ulink> products. In 
my case, an old Trace 4024 and an Outback MX-60.  </para>
+      <para>This all started when I bought a fixer upper, off-grid house... 
Like many projects, this one seems to have fallen into my lap, more than it was 
a concious idea. Over time, the concept has evolved into an actual product in 
development. That project, <ulink 
url="http://www.senecass.com/abelmon";>AbelMon</ulink>, is a much larger 
project, and this application , is part of that project spun off into a 
standalone application.</para>
+      <para>There are other similar products, but for WinDoze are <ulink 
url="http://www.righthandeng.com/";>Right Hand Engineer's Winverter</ulink> or 
<ulink url="http://www.mauisolarsoftware.com/";>Maui Solar Software's 
TraceTools</ulink>.</para>
+    </sect2>
   </sect1>
-
-  <sect1 id="PowerGuru Overview">
+  <sect1>
     <title>PowerGuru Overview</title>
-
-    <para>
-      PowerGuru is an interface to your inverter or charge
-      controller. It's main purpose is to handle the low-level
-      work of reading and writing from these devices. At this level
-      PowerGuru is an SDK for C,C++, or Java programers to work with
-      Xantrex and Outback Power Systems products.
-    </para>
-
-    <para>
-      The backend of PowerGuru is a daemon that runs all the time and
-      is connected via serial ports or USB to your power production
-      equipment. This daemon handles all the ugly work of interfacing
-      with each device. The daemon has two modes, one is data-logging
-      mode, and the other is a command mode.
-    </para>
-
-    <sect2 id="Project Goals">
+    <para>PowerGuru is an interface to your inverter or charge controller. 
It's main purpose is to handle the low-level work of reading and writing from 
these devices. At this level PowerGuru is an SDK for C,C++, or Java programers 
to work with Xantrex and Outback Power Systems products. </para>
+    <para>The backend of PowerGuru is a daemon that runs all the time and is 
connected via serial ports or USB to your power production equipment. This 
daemon handles all the ugly work of interfacing with each device. The daemon 
has two modes, one is data-logging mode, and the other is a command mode. 
</para>
+    <sect2>
       <title>Project Goals</title>
-
-      <para>
-       The goals of this are project are to make it easy to datalog or
-       remotely control your inverter or charge controller. The
-       daemon is designed to be reasonably small, so it can run on
-       12VDC low-power computer systems 24 hours a day, 7 days a
-       week. Since everything is done through a network interface, a
-       GUI can use the SDK to talk to the backend for all
-       functionality. This makes it easier for somebody (not me, I
-       suck at GUIs) to write good GUIs, without having to reverse
-       engineer these protocols like I have. I'd prefer to stick to
-       bit-twiddling.
-      </para>
-
-      <para>
-       If I'm not home, like on a business trip, I want to be able to
-       check on the status of my house while I'm gone. I have had
-       weird things happen like needing to reboot the charge
-       controller, or a few fuses in the combiner box blowing for no
-       apparent reason. I'd also like to be able to store the default
-       configuration settings for my inverter or controller, and set
-       a new one with my prefered default settings off disk after a
-       full system reset.
-      </para>
-
-      <para>
-       If a house is a rental and you are the landlord, or you have
-       an off-grid vacation house, or you are a solar installer, and
-       want to offer remote support for your customers as an
-       additional service, this is the type of thing I want PowerGuru
-       to support.
-      </para>
-
+      <para>The goals of this are project are to make it easy to datalog or 
remotely control your inverter or charge controller. The daemon is designed to 
be reasonably small, so it can run on 12VDC low-power computer systems 24 hours 
a day, 7 days a week. Since everything is done through a network interface, a 
GUI can use the SDK to talk to the backend for all functionality. This makes it 
easier for somebody (not me, I suck at GUIs) to write good GUIs, without having 
to reverse engineer these protocols like I have. I'd prefer to stick to 
bit-twiddling. </para>
+      <para>If I'm not home, like on a business trip, I want to be able to 
check on the status of my house while I'm gone. I have had weird things happen 
like needing to reboot the charge controller, or a few fuses in the combiner 
box blowing for no apparent reason. I'd also like to be able to store the 
default configuration settings for my inverter or controller, and set a new one 
with my prefered default settings off disk after a full system reset. </para>
+      <para>If a house is a rental and you are the landlord, or you have an 
off-grid vacation house, or you are a solar installer, and want to offer remote 
support for your customers as an additional service, this is the type of thing 
I want PowerGuru to support. </para>
     </sect2>
-
-    <sect2 id="Data Logging Mode">
+    <sect2>
       <title>PowerGuru Data Logging Mode</title>
-      
-      <para>
-       In this mode, the PowerGuru daemon just polls all the devices
-       that have output data, and writes it directly to an SQL
-       database. The time between data collection cycles can be set
-       by the user, since the amount of data can be huge, and doesn't
-       often vary much.
-      </para>
-      
+      <para>In this mode, the PowerGuru daemon just polls all the devices that 
have output data, and writes it directly to an SQL database. The time between 
data collection cycles can be set by the user, since the amount of data can be 
huge, and doesn't often vary much. </para>
     </sect2>
-
-    <sect2 id="Command Mode">
+    <sect2>
       <title>PowerGuru Command Mode</title>
-      
-      <para>
-       In this mode, the PowerGuru daemon acts as the remote agent to
-       control the device. Client programs use a network connection
-       (I'm contemplating using SNMP) to operate the commands
-       supported by each device. This enables the settings of each
-       device to be stored and set remotely.
-      </para>
-      
+      <para>In this mode, the PowerGuru daemon acts as the remote agent to 
control the device. Client programs use a network connection (I'm contemplating 
using SNMP) to operate the commands supported by each device. This enables the 
settings of each device to be stored and set remotely. </para>
     </sect2>
-
-    <sect2 id="User Interfaces">
+    <sect2>
       <title>User Interfaces</title>
-
-      <para>
-       There are two planned user interfaces for PowerGuru. One is web
-       based, and will enable the plotting of the logged data in
-       various forms. The other interface is designed to run standalone
-       without the need for a PHP enabled web server. It is also
-       designed to be run from a PDA or laptop in the field with a
-       direct serial connection to the device. This is for installers
-       so they can download the default settings they prefer to the
-       device, or extract the current device settings to store in a
-       disk file.
-      </para>
-
-      <sect3 id="Web Interface">
-       <title>Web Interface</title>
-
-       <para>
-         The web interface is written in PHP, and should be supported
-         by most all web servers and browsers. This is primarily a
-         data mining and display application to plot the power
-         readings in graphical manner. This UI is currently under
-         development.
-       </para>
-
+      <para>There are two planned user interfaces for PowerGuru. One is web 
based, and will enable the plotting of the logged data in various forms. The 
other interface is designed to run standalone without the need for a PHP 
enabled web server. It is also designed to be run from a PDA or laptop in the 
field with a direct serial connection to the device. This is for installers so 
they can download the default settings they prefer to the device, or extract 
the current device settings to store in a disk file. </para>
+      <sect3>
+        <title>Web Interface</title>
+        <para>The web interface is written in PHP, and should be supported by 
most all web servers and browsers. This is primarily a data mining and display 
application to plot the power readings in graphical manner. This UI is 
currently under development. </para>
       </sect3>
-
-      <sect3 id="Standalone Interface">
-       <title>Standalone Interface</title>
-
-       <para>
-         I want to be able to run PowerGuru on multiple systems,
-         namely Linux, Darwin, and Win32. The choice of a
-         cross-platform user interface toolkit that runs on all three
-         is not a trivial decision. Most PDAs these days runs Qtopia
-         (written in QT), PalmOS, or WinCE. Other than Java, a
-         language I truly dislike, the only multi-platform
-         solution supported on all platforms is QT. (called Qtopia on
-         a PDA) I'm not a GUI programer, I'm an embedded systems
-         type, so I'd prefer to only write the GUI once.
-       </para>
-
-       <para>
-         I have long prefered GTK+/GNOME over QT/KDE mostly cause I'm
-         a "free software" purist, and I'm not sure I want to learn
-         either QT or Java right now anyway. The original GUI for
-         PowerGuru back when it was still called "TraceGUI" was
-         written in GTK1.2, using the Glade prototyper. This can run
-         on Linux, Darwin and Win32, but not my PDA.
-       </para>
-
-       <para>
-         It is possible to run Tcl/Tk on most PDAs as an addon
-         package. For my Zaurus it needs an X11 environment (I run
-         OpenZaurus (a Debian port) on my Zaurus), plus Gentoo also
-         runs on the Zaurus with X11 support. There are also native
-         Tcl/Tk ports for PalmOS and WinCE, and it has a visual
-         development environment as well. I also used to be one of
-         the Tcl/Tk maintainers, so I wouldn't have the learning
-         curve and time drain of using QT or Java.
-       </para>
-
+      <sect3>
+        <title>Standalone Interface</title>
+        <para>I want to be able to run PowerGuru on multiple systems, namely 
Linux, Darwin, and Win32. The choice of a cross-platform user interface toolkit 
that runs on all three is not a trivial decision. Most PDAs these days runs 
Qtopia (written in QT), PalmOS, or WinCE. Other than Java, a language I truly 
dislike, the only multi-platform solution supported on all platforms is QT. 
(called Qtopia on a PDA) I'm not a GUI programer, I'm an embedded systems type, 
so I'd prefer to only write the GUI once. </para>
+        <para>I have long preferred GTK+/GNOME over QT/KDE mostly cause I'm a 
"free software" purist, and I'm not sure I want to learn either QT or Java 
right now anyway. The original GUI for PowerGuru back when it was still called 
"TraceGUI" was written in GTK1.2, using the Glade prototyper. This can run on 
Linux, Darwin and Win32, but not my PDA. </para>
+        <para>It is possible to run Tcl/Tk on most PDAs as an addon package. 
For my Zaurus it needs an X11 environment (I run OpenZaurus (a Debian port) on 
my Zaurus), plus Gentoo also runs on the Zaurus with X11 support. There are 
also native Tcl/Tk ports for PalmOS and WinCE, and it has a visual development 
environment as well. I also used to be one of the Tcl/Tk maintainers, so I 
wouldn't have the learning curve and time drain of using QT or Java. </para>
       </sect3>
-
     </sect2>
-
   </sect1>
-
-  <sect1 id="Protocol Reference">
+  <sect1>
     <title>Protocol Reference</title>
-
-    <para>
-      PowerGuru supports multiple protocols, since it supports
-      multiple devices. As documentation of these protocols is often
-      non-existant or there is a lot of supporting info needed by
-      developers that isn't covered in the existing manuals, I figured
-      I'd document my experiences with these systems from my
-      perspective as an embedded systems engineer with over 25 years
-      experience.
-    </para>
-
-    &xantrexdoc;
-
-    &outbackdoc;
-
+    <para>PowerGuru supports multiple protocols, since it supports multiple 
devices. As documentation of these protocols is often non-existant or there is 
a lot of supporting info needed by developers that isn't covered in the 
existing manuals, I figured I'd document my experiences with these systems from 
my perspective as an embedded systems engineer with over 25 years experience. 
</para>
   </sect1>
-
-<!-- ============= Authors ================================ -->
-
-  <sect1 id="authors">
+  <sect1>
     <title>Authors</title>
-    <para>
-      <application>PowerGuru</application> was written by Rob Savoye
-      (<email>address@hidden</email>).  Please send all comments,
-      suggestions, and bug reports to <email>address@hidden</email>. 
-      I am available for consulting on a variety of renewable energy
-      and open source technologies. More details at <ulink type="http"
-      url="http://www.senecass.com";>http://www.senecass.com</ulink>
-   </para>
-
+    <para><application>PowerGuru</application> was written by Rob Savoye 
(address@hidden). Please send all comments, suggestions, and bug reports to 
address@hidden I am available for consulting on a variety of renewable energy 
and open source technologies. More details at <ulink 
url="http://www.senecass.com/";>http://www.senecass.com</ulink> </para>
   </sect1>
-
-  <!-- ============= Application License ============================= -->
-
-  <sect1 id="license">
-   <title>License</title>
-   <para>
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the <citetitle>GNU General Public
-    License</citetitle> as published by the Free Software Foundation;
-    either version 2 of the License, or (at your option) any later
-    version.
-   </para>
-   <para>
-    This program is distributed in the hope that it will be useful, but
-    WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    <citetitle>GNU General Public License</citetitle> for more details.
-   </para>
-   <para>
-    A copy of the <citetitle>GNU General Public License</citetitle> is
-    included as an appendix to the <citetitle>GNOME Users
-    Guide</citetitle>.  You may also obtain a copy of the
-    <citetitle>GNU General Public License</citetitle> from the Free
-    Software Foundation by visiting <ulink type="http"
-    url="http://www.fsf.org";>their Web site</ulink> or by writing to
-    <address>
-     Free Software Foundation, Inc.
-     <street>51 Franklin St, Fifth Floor</street>
-     <city>Boston</city>, <state>MA</state> <postcode>02111-1301</postcode>
-     <country>USA</country>
-    </address>
-   </para>
+  <sect1>
+    <title>License</title>
+    <para>This program is free software; you can redistribute it and/or modify 
it under the terms of the GNU General Public License as published by the Free 
Software Foundation; either version 2 of the License, or (at your option) any 
later version. </para>
+    <para>This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
details. </para>
+    <para>A copy of the GNU General Public License is included as an appendix 
to the GNOME Users Guide. You may also obtain a copy of the GNU General Public 
License from the Free Software Foundation by visiting <ulink 
url="http://www.fsf.org/";>their Web site</ulink> or by writing to Free Software 
Foundation, Inc. 51 Franklin St, Fifth Floor Boston, MA 02111-1301 USA </para>
   </sect1>
 </article>
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 766165a..75d994e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -36,10 +36,10 @@ libpguru_la_CPPFLAGS =      -I$(top_srcdir)/devices
 libpguru_la_LIBDADD =
 
 #      err.cc err.h
-#      log.cc log.h
 libpguru_la_SOURCES = \
        proc.cc proc.h \
        rc.cc rc.h \
+       log.cc log.h \
        console.cc console.h \
        database.h \
        tcputil.cc tcputil.h \
@@ -74,7 +74,6 @@ endif
 
 include_HEADERS = \
        proc.h \
-       serial.h \
        menuitem.h \
        database.h \
        console.h \
diff --git a/lib/commands.cc b/lib/commands.cc
index 36e3857..6c528c8 100644
--- a/lib/commands.cc
+++ b/lib/commands.cc
@@ -27,12 +27,16 @@
 #include <unistd.h>
 #include <cstring>
 #include <vector>
+#include <thread>
 #include "xml.h"
 #include "log.h"
 #include "commands.h"
-#include <thread>
 
-extern LogFile dbglogfile;
+//    <NOP></NOP>
+//    <LIST><DEVICES></DEVICES></LIST>
+//    <POLL><DEVICE>name</DEVICE></POLL>
+//    <POLL><INTERVAL>seconds</INTERVAL></POLL>
+//    <HELO></HELO>
 
 Commands::Commands()
 {
@@ -50,30 +54,28 @@ Commands::~Commands()
 }
 
 std::string &
-Commands::createCommand(cmd_t cmd, const std::string &args,
-                        std::string &str)
+Commands::createNode(cmd_t cmd, const std::string &args,
+                               std::string &str)
 {
     //DEBUGLOG_REPORT_FUNCTION;
-    
-    str.clear();
-    str = "<command>";
+
     switch (cmd) {
       case LIST:
-          dbglogfile << "create LIST command" << std::endl;
+          BOOST_LOG(lg) << "create LIST command" << std::endl;
           str += "<list>" + args + "</list>";
           break;
       case POLL:
-          dbglogfile << "create POLL command" << std::endl;  
+          BOOST_LOG(lg) << "create POLL command" << std::endl;  
           str += "<poll>" + args + "</poll>";
           break;
       case NOP:
-          dbglogfile << "create NOP command" << std::endl;  
+          BOOST_LOG(lg) << "create NOP command" << std::endl;  
           str += "<nop>" + args + "</nop>";
           break;
       case HELO:
           // This takes two optional arguments, the first one
           // is the hostname, the second the user name.
-          dbglogfile << "create HELO command" << std::endl;
+          BOOST_LOG(lg) << "create HELO command" << std::endl;
           std::string data = "<hostname>";
           size_t pos = args.find(' ');
           if (pos == std::string::npos) {
@@ -92,7 +94,19 @@ Commands::createCommand(cmd_t cmd, const std::string &args,
           break;
     };
     
-    str += "</command>\n";
+    return str;
+}
+
+std::string &
+Commands::createCommand(cmd_t cmd, const std::string &args,
+                        std::string &str)
+{
+    //DEBUGLOG_REPORT_FUNCTION;
+    
+    std::string newstr = "<command>";
+    newstr += str;
+    newstr += "</command>\n";
+    str = newstr;
 
     return str;
 }
@@ -104,7 +118,7 @@ Commands::execCommand(XML &xml, std::string &str)
 
     std::string cmd = xml.nameGet();
     
-    dbglogfile << "Executing remote command " << cmd << std::endl;
+    BOOST_LOG(lg) << "Executing remote command " << cmd << std::endl;
 
     // The first child node is the top level command
     if (xml[0]->nameGet() == "list") {
diff --git a/lib/commands.h b/lib/commands.h
index a7fe69f..2b8ffe4 100644
--- a/lib/commands.h
+++ b/lib/commands.h
@@ -28,7 +28,6 @@
 #include <vector>
 #include <map>
 #include "xml.h"
-#include "log.h"
 
 class Commands 
 {
@@ -36,6 +35,8 @@ public:
     typedef enum { NOP, LIST, POLL, HELO } cmd_t; 
     Commands();
     ~Commands();
+    std::string &createNode(cmd_t cmd, const std::string &args,
+                               std::string &str);
     std::string &createCommand(cmd_t cmd, const std::string &args,
                                std::string &str);
     std::string &execCommand(XML &xml, std::string &str);
diff --git a/lib/console.cc b/lib/console.cc
index 5b05848..540af40 100644
--- a/lib/console.cc
+++ b/lib/console.cc
@@ -169,7 +169,7 @@ Console::sendEOL (void) {
 void
 signal_handler (int sig)
 {
-    dbglogfile << "Got a " << sig << " from the console" << endl;
+    BOOST_LOG(lg) << "Got a " << sig << " from the console" << endl;
     exit(sig);
 }
 
diff --git a/lib/log.cc b/lib/log.cc
index 83a6a5c..c87ddd7 100644
--- a/lib/log.cc
+++ b/lib/log.cc
@@ -1,620 +1,47 @@
+// 
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+//               2014, 2015, 2016, 2017, 2018, 2019
+// Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 #include <iomanip>
 #include <fstream>
 #include <cstring>
-// #include <strstream>
-
-// Target Manager internal logging sub-system
-#include "log.h"
-
-// Required for SYSTEMTIME definitions
-#ifdef _WIN32
+#ifdef _WIN32                   // Required for SYSTEMTIME definitions
 #include <windows.h>
 #endif // _WIN32
-
 #include <time.h>
+#include "log.h"
 
-# if 0
-std::ofstream LogFile::outstream;
-string LogFile::logentry;
-bool LogFile::stamp;
-enum LogFile::file_state LogFile::state;
-#endif
-std::ofstream LogFile::console;
-int LogFile::verbose;
-
-const unsigned char hexchars[]="0123456789abcdef";
-
-// Instantiate the log file
-LogFile dbglogfile;
-
-extern "C" char digit2hex(int);
-extern "C" int hex2digit (int);
-
-
-std::ostream& operator<<(std::ostream& os, Verbose& b) {
-    // dbglogfile.verbosity(b);
-    return os;
-}
-
-#if 0
-std::ostream& stampon(std::ostream& x) {
-    LogFile::stamp(true);
-    return x;
-}
-
-std::ostream& stampoff(std::ostream& x) {
-    LogFile::SetStamp(false);
-    return x;
-}
-#endif
-
-std::ostream& timestamp(std::ostream& x) {
-    time_t t;
-    char buf[10];
-
-    memset (buf, '0', 10);     // this terminates the string
-    time (&t);                 // get the current time
-    strftime (buf, sizeof(buf), "%H:%M:%S", localtime (&t));
-
-    return x << buf << ": ";
-}
-
-std::string &timestamp(std::string &str) {
-    time_t t;
-    char buf[10];
-
-    memset (buf, '0', 10);     // this terminates the string
-    time (&t);                 // get the current time
-    strftime (buf, sizeof(buf), "%H:%M:%S", localtime (&t));
-    str = buf;
-
-    return str;
-}
-
-std::ostream& datetimestamp(std::ostream& x) {
-    time_t t;
-    char buf[20];
-
-    memset (buf, '0', 20);     // this terminates the string
-    time (&t);                 // get the current time
-    strftime (buf, sizeof(buf), "%Y-%m-%d %H:%M:%S ", localtime (&t));
-
-    return x << buf;
-}
-
-// FIXME: This controls the entire output stream
-#if 0
-std::ostream & operator << (std::ostream &os, std::string x) {
-    if (dbglogfile.get_verbosity() > 0)
-       cout << timestamp << x;
-    return os << x.c_str();
-}
-#endif
-
-std::ostream &operator<<(std::ostream &os, LogFile &l) {
-    return os << l.GetEntry();
-}
-
-// Make sure we can print outself to an output stream
-
-const char *
-LogFile::GetEntry(void) {
-    return logentry.c_str();
-}
-
-// Default constructor
-LogFile::LogFile (void) {
-    verbose = 0;
-    stamp = true;
-    LogFile::outstream.open (DEFAULT_LOGFILE, std::ios::out);
-    state = OPEN;
-}
-
-LogFile::LogFile (const char *filespec) {
-    verbose = 0;
-    stamp = true;
-    if (state == OPEN)
-        LogFile::outstream.close ();
-    LogFile::outstream.open (filespec, std::ios::out);
-    state = OPEN;
-}
-
-retcode_t
-LogFile::Open (const char *filespec) {
-    if (state == OPEN)
-        LogFile::outstream.close ();
-    LogFile::outstream.open (filespec, std::ios::out);
-    state = OPEN;
-  
-    // LogFile::outstream << "Opened " << filespec << std::endl;
-  
-    return SUCCESS;
-}
-
-retcode_t
-LogFile::Close (void) {
-    LogFile::outstream.flush ();
-    if (state == OPEN)
-        LogFile::outstream.close ();
-    //    state = CLOSED;
-    
-    return SUCCESS;
-}
-
-LogFile&
-LogFile::operator << (long x)
-{
-    if (verbose > 0)
-        std::cout << x;
-    LogFile::outstream << x;
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (unsigned int x)
-{
-    if (verbose > 0)
-        std::cout << x;
-    LogFile::outstream << x;
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (float x)
-{ 
-    LogFile::outstream << x;
-    if (verbose > 0) {
-        std::cout << x;
-    }
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (double &x)
-{
-    LogFile::outstream << x; 
-    if (verbose > 0) {
-        std::cout << x;
-    }
-  
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (bool x)
-{
-    LogFile::outstream << x;
-    if (verbose > 0) {
-        std::cout << x;
-    }
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (int x) {
-    
-    if (verbose > 0)
-        std::cout << x;
-    LogFile::outstream << x;
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile&
-LogFile::operator << (void *ptr) {
-    
-    if (verbose > 0)
-        std::cout << ptr;
-    LogFile::outstream << ptr;
-    state = INPROGRESS;
-
-    return *this;
-}
-
-LogFile& 
-LogFile::operator << (const std::string &str) {
-    //outstream << s.c_str();
-    std::string date;
-    logentry = timestamp(date);
-    logentry += ": ";
-
-    if (stamp == true && (state == IDLE || state == OPEN)) {
-        LogFile::state = INPROGRESS;
-       if (verbose > 0)
-           std::cout << logentry  << str;
-        outstream << logentry << str;
-    } else {
-       if (verbose > 0)
-           std::cout << str;
-        outstream << str;
-    }
-//    logentry += str;
-
-    return *this;
-}
-
-LogFile& 
-LogFile::operator << (const char *c) {
-    std::string str;
-    logentry = timestamp(str);
-    logentry += ": ";
-
-    if (stamp == true && (state == IDLE || state == OPEN)) {
-        LogFile::state = INPROGRESS;
-       if (verbose > 0)
-           std::cout << logentry  << c;
-        outstream << logentry << c;
-    } else {
-       if (verbose > 0)
-           std::cout << c;
-        outstream << c;
-    }
-    logentry += c;
-
-    return *this;
-}
-
-LogFile& 
-LogFile::operator << (const unsigned char *c) {
-    std::string str;
-    logentry = timestamp(str);
-    logentry += ": ";
-
-    if (c == NULL) {
-        return *this;
-    }
-    
-    if (stamp == true && (state == IDLE || state == OPEN)) {
-        LogFile::state = INPROGRESS;
-       if (verbose > 0)
-           std::cout << logentry  << c;
-        outstream << logentry << c;
-    } else {
-       if (verbose > 0)
-           std::cout << c;
-        outstream << c;
-    }
-    logentry += (const char*)c;
-
-    return *this;
-}
-
-// This grabs the endl operator;
-std::ostream&
-LogFile::operator << (std::ostream & (&)(std::ostream &)) {
-    if (verbose > 0)
-        std::cout << "\r" << std::endl;
-    LogFile::outstream << std::endl;;
-    LogFile::outstream.flush();
-    LogFile::state = IDLE;
-
-    // FIXME: This is probably not the value to return
-    return std::cout;
-}
-
-#if 0
-// This is a logging function. All messages get logged as a time stamped
-// entry to the disk log file. The optionally get displayed via the
-// printf_filtered() function, which is defined by the program that links
-// in the target manager client library.
-retcode_t
-LogFile::note (int level, const char *fmt, ...) {
-    va_list ap;
-    char tmp[LOGBUFFERSIZE];
-    char buf[TIMESTAMP_LENGTH];
-#ifdef _WIN32
-    SYSTEMTIME system_time, local_time;
-#else
-    time_t t;
-#endif // _WIN32
-    const char *errmsg;
-
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
-    
-// use SYSTEMTIME under Windows for millisecond resolution
-#ifdef _WIN32
-    GetSystemTime (&system_time); // get the current time
-    SystemTimeToTzSpecificLocalTime (NULL, &system_time, &local_time);
-    sprintf (buf, "%02u:%02u:%02u.%03u", local_time.wHour,
-
-             local_time.wMinute, local_time.wSecond, local_time.wMilliseconds);
-#else
-    time (&t);                 // get the current time
-    strftime (buf, sizeof(buf), "%H:%M:%S", localtime (&t));
-#endif // _WIN32
-    // Some messages already come with a newline on the end, which we
-    // don't want.
-    if (*(tmp+strlen(tmp)-1) == '\n')
-        *(tmp+strlen(tmp)-1) = '\0';
-
-    // Since we're running either the curse UI or a X11 GUI, we
-    // don't ever print log messages to the screen.
-#if 0
-    if (verbose >= level) {
-        std::cout << tmp;       ;
-        std::cout.flush();
-    }
-#endif
-
-    // write the message with a timestamp to the log file
-    if (state == OPEN) {
-        logout << buf << ":" << tmp << std::endl;
-        logout.flush();
-    }
-
-    va_end (ap);
-    return SUCCESS;
-}
-
-retcode_t
-LogFile::printf (int level, const char *fmt, ...) {
-    va_list ap;
-    char tmp[LOGBUFFERSIZE];
-    char buf[10];
-    const char *errmsg;
-    
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
-    
-    // Since we're running either the curse UI or a X11 GUI, we
-    // don't ever print log messages to the screen.
-#if 0
-    if (verbose >= level) {
-        std::cout << tmp;
-        std::cout.flush();
-    }
-#endif    
-
-    // write the message with a timestamp to the log file
-    if (state == OPEN) {
-        logout << tmp;
-        logout.flush();
-    }
-    
-    va_end (ap);    
-    return SUCCESS;
-}
-
-// Unconditionally print an error message
-void
-LogFile::error (const char *fmt, ...) {
-    va_list ap;
-    char tmp[LOGBUFFERSIZE];
-    char buf[10];
-    
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
-    
-    LogFile::note (0, "ERROR: %s", tmp);
-    
-    va_end (ap);
-}
-
-// Unconditionally print a warning message
-void
-LogFile::warning (const char *fmt, ...) {
-    va_list ap;
-    char tmp[LOGBUFFERSIZE];
-    char buf[10];
-    
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
-    
-    LogFile::note (0, "WARNING: %s", tmp);
-    
-    va_end (ap);
-}
-
-// Print an informational message, which is printed at level 1
-void
-LogFile::info (const char *fmt, ...) {
-    va_list ap;
-    char tmp[LOGBUFFERSIZE];
-    char buf[10];
-    
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
-    
-    LogFile::note (1, "%s", tmp);
-    
-    va_end (ap);
-}
+src::logger lg;
 
-// Print an informational message, which is printed at level 1
 void
-LogFile::info (char *str) {
-    LogFile::note (1, "%s", str);
-}
-
-// These wrap a C API around the C++ one
-// C wrappers for the C++ functions
-extern "C" void
-debuglog_error (const char *fmt, ...) 
-{
-    va_list ap;
-    va_start (ap, fmt);
-    dbglogfile.note (0, fmt, ap);
-    va_end (ap);
-}
-
-extern "C" void
-debuglog_warning (const char *fmt, ...) 
-{
-    va_list ap;
-    va_start (ap, fmt);
-    dbglogfile.note (0, fmt, ap);
-    va_end (ap);
-}
-
-extern "C" void
-debuglog_info (const char *fmt, ...) 
-{
-    va_list ap;
-    va_start (ap, fmt);
-    dbglogfile.note (1, fmt, ap);
-    va_end (ap);
-}
-
-extern "C" void
-debuglog_note (unsigned int level, const char *fmt, ...) 
-{
-    va_list ap;
-    va_start (ap, fmt);
-    dbglogfile.note (level, fmt, ap);
-    va_end (ap);
-}
-
-extern "C" void
-debuglog_set_verbosity (void) 
+log_init(const std::string &name)
 {
-    dbglogfile.set_verbosity ();
-}
-
-extern "C" int
-debuglog_get_verbosity (void) 
-{
-    return dbglogfile.get_verbosity ();
-}
-
-extern "C" int 
-debuglog_open (const char *filespec) {
-    return dbglogfile.open (filespec);
-}
-
-extern "C" void
-logfile_printf (int level, const char *fmt, ...) {
-    va_list ap;
-    char tmp[3000];
-    
-    // FIXME: for some odd reason, uncommenting this causes an
-    // infinite loop.
-    // REPORT_FUNCTION;
-    va_start (ap, fmt);
-    vsprintf (tmp, fmt, ap);
+    logging::formatter formatter = expr::stream
+        << expr::format_date_time< boost::posix_time::ptime >
+        ("TimeStamp", "[%Y-%m-%d %H:%M:%S] ") << expr::message;
     
-    dbglogfile.printf (level, "%S", tmp);
-}
-
-// Convert a buffer into an ascified representation. ie.. ^C is 0x03, etc...
-extern "C" unsigned char *
-ascify_buffer (unsigned char *p, const unsigned char *s, int x) {
-    int i;
-    unsigned char *p1 = p;
-
-//    dbglogfile.note (3, "ascify_buffer: convert %d bytes.", x);
-    // convert some characters so it'll look right in the log
-    for (i=0 ; i<x; i++) {
-//        dbglogfile.note (3, "\tascify 0x%x", s[i]);
-        switch (s[i]) {
-          case '\012':         // newlines
-              *p++ = '\\';
-              *p++ = 'n';
-              continue;
-          case '\015':         // carriage returns
-              *p++ = '\\';
-              *p++ = 'r';
-              continue;
-          case '\033':         // escape
-              *p++ = '\\';
-              *p++ = 'e';
-              continue;
-          case '\011':         // tab
-              *p++ = '\\';
-              *p++ = 't';
-              continue;
-          case '\010':         // backspace
-              *p++ = '\\';
-              *p++ = 'b';
-              continue;
-        }
-        
-        if (s[i] < 26) {       // modify control characters
-            *p++ = '^';
-            *p++ = s[i] + '@';
-            continue;
-        }
-        if (s[i] >= 128) {     // modify control characters
-            *p++ = '!';
-            *p++ = s[i] + '@';
-            continue;
-        }
-        if (s[i] > 26 && s[i] < 128) { // no change
-            *p++ = s[i];
-            continue;
-        }
-    }
-
-    *p = '\0';                 // terminate the string
-
-    return p1;
-}
-
-// Convert each byte into it's hex represntation
-unsigned char *
-hexify_buffer (unsigned char *p, const unsigned char *s, int x) {
-    int i;
-    unsigned char *p1 = p;
+    logging::add_file_log(name + ".log")->set_formatter(formatter);
+    logging::add_console_log()->set_formatter(formatter);
 
-    dbglogfile.note (3, "hexify_buffer: convert %d bytes.", x);
-    // convert some characters so it'll look right in the log
-    for (i=0 ; i<x; i++) {
-        // use the hex value
-        *p++ = hexchars[s[i] >> 4];
-        *p++ = hexchars[s[i] & 0xf];
-        *p++ = ' ';
-//        dbglogfile.note (3, "\thexify s[%d] = 0x%02x", i, s[i]);
-    }
-
-    *p = '\0';                                  // terminate the string
-
-    return p1;
-}
-
-// convert number NIB to a hex digit.
-//      param is a decimal digit.
-//      returns a hex digit.
-extern "C" char
-digit2hex(int digit) {
-    if (digit < 10)
-        return '0' + digit;
-    else
-        return 'a' + digit - 10;
-}
-
-// convert an ascii hex digit to a number.
-//      param is hex digit.
-//      returns a decimal digit.
-extern "C" int
-hex2digit (int digit)
-{
-    if (digit == 0)
-        return 0;
-
-    if (digit >= '0' && digit <= '9')
-        return digit - '0';
-    if (digit >= 'a' && digit <= 'f')
-        return digit - 'a' + 10;
-    if (digit >= 'A' && digit <= 'F')
-        return digit - 'A' + 10;
-
-    /* shouldn't ever get this far */
-    return -1;
+    // Register common attributes
+    logging::add_common_attributes();
 }
 
-#endif
-
 // local Variables:
 // mode: C++
 // indent-tabs-mode: nil
diff --git a/lib/log.h b/lib/log.h
index 7c6a55b..9a63680 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -1,6 +1,7 @@
 // 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
-//      Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+//               2014, 2015, 2016, 2017, 2018, 2019
+// Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -20,6 +21,7 @@
 #define __LOG_H__
 
 // This is generated by autoconf
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -27,15 +29,6 @@
 // Target Manager error sub-system
 #include "err.h"
 
-// This is so we don't get warning from strncpy()
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-
 #ifdef __cplusplus
 
 #include <time.h>
@@ -45,114 +38,60 @@
 #include <cstring>
 #include <fstream>
 
+#include <boost/log/core.hpp>
+#include <boost/log/trivial.hpp>
+#include <boost/log/expressions.hpp>
+#include <boost/log/sinks/text_file_backend.hpp>
+#include <boost/log/sinks/basic_sink_frontend.hpp>
+#include <boost/log/utility/setup/file.hpp>
+#include <boost/log/utility/setup/console.hpp>
+#include <boost/log/utility/setup/common_attributes.hpp>
+#include <boost/log/utility/setup/filter_parser.hpp>
+#include <boost/log/utility/setup/formatter_parser.hpp>
+#include <boost/log/sources/severity_logger.hpp>
+#include <boost/core/null_deleter.hpp>
+#include <boost/log/sources/record_ostream.hpp>
+#include <boost/log/sinks/text_ostream_backend.hpp>
+#include <boost/log/common.hpp>
+#include <boost/log/attributes.hpp>
+#include <boost/log/sinks.hpp>
+#include <boost/log/sources/logger.hpp>
+#include <boost/log/support/date_time.hpp>
+namespace logging = boost::log;
+namespace attrs = boost::log::attributes;
+namespace src = boost::log::sources;
+namespace sinks = boost::log::sinks;
+namespace expr = boost::log::expressions;
+namespace keywords = boost::log::keywords;
+
+extern src::logger lg;
+
+extern void log_init(const std::string &name);
+
 // the default name for the debug log
 #define DEFAULT_LOGFILE        "powerguru-dbg.log"
 #define TIMESTAMP_LENGTH 24             // timestamp length
 #define TIMESTAMP_FORMAT "%Y-%m-%d %H:%M:%S     " // timestamp format
 
-extern std::ostream &stampon(std::ostream& x);
-extern std::ostream &stampoff(std::ostream& x);
-extern std::ostream &timestamp(std::ostream& x);
-extern std::ostream &datetimestamp(std::ostream& x);
-
-// Print a number in binary:
-class Verbose {
-    int level;
-public:
-    Verbose(int l) { level = l; }
-    friend std::ostream &operator<<(std::ostream &, Verbose &);
-};
-
-// Get the current timestamp
-std::string &timestamp(std::string &);
-
-// This is a basic file logging class
-class LogFile { // public std::ofstream {
-public:
-    LogFile (void);
-    LogFile (const char *);
-    ~LogFile(void) {
-        if (state == OPEN) {
-            //      flush();
-            //      state = CLOSED;
-            Close();
-        }
-    }
-    enum file_state {
-        CLOSED,
-        OPEN,
-        INPROGRESS,
-        IDLE
-    } state;
-  
-    file_state GetState (void) { return state; }
-    LogFile &operator << (int x);
-    LogFile &operator << (long x);
-    LogFile &operator << (unsigned int x);
-    // These both resolve to an unsigned int.
-    // LogFile& operator << (size_t x);
-    // LogFile& operator << (time_t x);
-    LogFile &operator << (float x);
-    LogFile &operator << (double &x);
-    LogFile &operator << (bool x);
-    LogFile &operator << (void *);
-    LogFile &operator << (const char *);
-    LogFile &operator << (const unsigned char *);
-    LogFile &operator << (const std::string &);
-    std::ostream& operator << (std::ostream & (&)(std::ostream &));
-    const char *GetEntry(void);
-  
-    retcode_t Open(const char *);
-    retcode_t Close(void);
-    // accessors for the verbose level
-    void set_verbosity (void) {
-        verbose++;
-        //        note (3, "Verbosity now set to %d", verbose);
-    }
-    void set_verbosity (int x) {
-        verbose = x;
-        //        note (3, "Verbosity now set to %d", verbose);
-    }
-
-    void SetStamp (bool b) {
-        stamp = b;
-    }
-    bool GetStamp (void) {
-        return stamp;
-    }
-    //std::string gettimestamp();
-  
-private:
-    static std::ofstream console;
-    std::ofstream outstream;
-    static int verbose;
-    bool stamp;
-    std::string logentry;
-    friend std::ostream & operator << (std::ostream &os, LogFile& e);
-};
-
-extern LogFile dbglogfile;
-
 struct __Host_Function_Report__ {
     const char *func;
-
+    src::logger lg;
     __Host_Function_Report__(void) {
-        if (dbglogfile.GetState() == LogFile::OPEN)
-            dbglogfile  << "enter" << std::endl;
+        BOOST_LOG(lg) << "enter";
     }
 
     __Host_Function_Report__(char *_func) {
         func = _func;
-       dbglogfile << func << " enter" << std::endl;
+       BOOST_LOG(lg) << func << " enter";
     }
 
     __Host_Function_Report__(const char *_func) {
         func = _func;
-       dbglogfile << func << " enter" << std::endl;
+       BOOST_LOG(lg) << func << " enter";
     }
 
     ~__Host_Function_Report__(void) {
-       dbglogfile << func << " return" << std::endl;
+       BOOST_LOG(lg) << func << " return";
     }
 };
 
@@ -165,8 +104,8 @@ unsigned char *
 ascify_buffer (unsigned char *p, const unsigned char *s, int x);
 
 #else
-#define DEBUGLOG_REPORT_FUNCTION printf("%s entered\n", __FUNCTION__)
-#define DEBUGLOG_REPORT_RETURN printf("%s return\n", __FUNCTION__)
+# define DEBUGLOG_REPORT_FUNCTION printf("%s entered\n", __FUNCTION__)
+# define DEBUGLOG_REPORT_RETURN printf("%s return\n", __FUNCTION__)
 
 // __cplusplus
 #endif
diff --git a/lib/mariadb.cc b/lib/mariadb.cc
index 5fd997f..3e7826c 100644
--- a/lib/mariadb.cc
+++ b/lib/mariadb.cc
@@ -99,7 +99,7 @@ Database::openDB (void)
 
     unsigned long flag = 0;
 
-    dbglogfile <<"Connecting to MySQL database "  << _dbname.c_str()
+    BOOST_LOG(lg) <<"Connecting to MySQL database "  << _dbname.c_str()
                << " on " << _dbhost.c_str()
                << " as user " << _dbuser.c_str() << endl;
 
@@ -110,11 +110,11 @@ Database::openDB (void)
     /* check for a connection error */
     if(_connection == NULL) {
         /* print the error message */
-        dbglogfile << "MySQL error when connecting: \n" << 
mysql_error(&_mysql) << endl;
+        BOOST_LOG(lg) << "MySQL error when connecting: \n" << 
mysql_error(&_mysql) << endl;
         return false;
     }
     
-    dbglogfile << "Connected to MySQL database " << _dbname.c_str()
+    BOOST_LOG(lg) << "Connected to MySQL database " << _dbname.c_str()
                <<  " on host " <<_dbhost.c_str() << endl;
     
 #if 0
@@ -145,13 +145,13 @@ Database::queryInsert(const char *query)
   
     retries = 2;
   
-    dbglogfile << "Query is: " << query << endl;
+    BOOST_LOG(lg) << "Query is: " << query << endl;
   
 #if 0
     string str = query;
     // FIXME: We shouldn't ever get this condition
     if (str.find("INSERT", 10) != string::npos) {        
-        dbglogfile << "Extra INSERT in query!\n", query << endl;
+        BOOST_LOG(lg) << "Extra INSERT in query!\n", query << endl;
     }
 #endif
   
@@ -162,7 +162,7 @@ Database::queryInsert(const char *query)
           case CR_SERVER_LOST:
           case CR_COMMANDS_OUT_OF_SYNC:
           case CR_SERVER_GONE_ERROR:
-              dbglogfile << "MySQL connection error: " << mysql_error(&_mysql) 
<< endl;
+              BOOST_LOG(lg) << "MySQL connection error: " << 
mysql_error(&_mysql) << endl;
               // Try to reconnect to the database
               closeDB();
               openDB();
@@ -170,16 +170,16 @@ Database::queryInsert(const char *query)
               break;
           case -1:
           case CR_UNKNOWN_ERROR:
-              dbglogfile << "MySQL error on query for:\n\t " <<
+              BOOST_LOG(lg) << "MySQL error on query for:\n\t " <<
                   mysql_error(&_mysql) << endl;
-              dbglogfile << "Query was: " << query << endl;
+              BOOST_LOG(lg) << "Query was: " << query << endl;
               return false;
               break;            
           default:
               return true;
         }
     
-        dbglogfile << "Lost connection to the database server, shutting 
down..." << endl;
+        BOOST_LOG(lg) << "Lost connection to the database server, shutting 
down..." << endl;
         
         return false;
     }
@@ -199,7 +199,7 @@ Database::queryResults(const char *query)
     int         nrows;
     unsigned int i, res;
 
-    dbglogfile << "Query is: " << query << endl;
+    BOOST_LOG(lg) << "Query is: " << query << endl;
 
     res = mysql_real_query(&_mysql, query, strlen(query));
     
@@ -208,14 +208,14 @@ Database::queryResults(const char *query)
           case CR_SERVER_LOST:
           case CR_COMMANDS_OUT_OF_SYNC:
           case CR_SERVER_GONE_ERROR:
-              dbglogfile << "MySQL connection error: "
+              BOOST_LOG(lg) << "MySQL connection error: "
                          << mysql_error(&_mysql) << endl;
               // Try to reconnect to the database
               closeDB();
               openDB();
               break;
           case CR_UNKNOWN_ERROR:
-              dbglogfile << "MySQL error on query for:" << 
mysql_error(&_mysql) << endl;
+              BOOST_LOG(lg) << "MySQL error on query for:" << 
mysql_error(&_mysql) << endl;
 //        ACE_DEBUG((LM_INFO, "Query was: %s\n", query));
 //        return false;
 //      default:
@@ -258,7 +258,7 @@ Database::queryInsert(vector<meter_data_t *> data)
     ostringstream  query;
 
     if (data.size() == 0) {
-        dbglogfile << "No data to insert." << endl;
+        BOOST_LOG(lg) << "No data to insert." << endl;
         return false;
     }
   
diff --git a/lib/menuitem.cc b/lib/menuitem.cc
index 47d012a..d06705e 100644
--- a/lib/menuitem.cc
+++ b/lib/menuitem.cc
@@ -249,61 +249,61 @@ MenuItem::Dump(void)
 #endif
 
     if (type <= ENUM) {
-        dbglogfile << " Label is: \"" << label << "\"" << endl;
+        BOOST_LOG(lg) << " Label is: \"" << label << "\"" << endl;
     }
-    dbglogfile << "\tHeader Index: "   << headidx;
-    dbglogfile << ", Item Index: " << itemidx;
+    BOOST_LOG(lg) << "\tHeader Index: "   << headidx;
+    BOOST_LOG(lg) << ", Item Index: " << itemidx;
 
     if (cmdname.size() > 0)
-        dbglogfile << ", Alias is: \"" << cmdname << "\"";
-    dbglogfile << endl;
+        BOOST_LOG(lg) << ", Alias is: \"" << cmdname << "\"";
+    BOOST_LOG(lg) << endl;
   
     switch (type) {
       case NONE:
-          dbglogfile << "\tUnitialized data type." << endl;
+          BOOST_LOG(lg) << "\tUnitialized data type." << endl;
           break;
       case INFO:
-          dbglogfile << "\tInformational Message." << endl;
+          BOOST_LOG(lg) << "\tInformational Message." << endl;
           break;
       case MENUHEAD:
-          dbglogfile << "\tMenu Heading" << endl;
+          BOOST_LOG(lg) << "\tMenu Heading" << endl;
           break;
       case MENUITEM:
-          dbglogfile << "\tMenu Item: "<< endl;
+          BOOST_LOG(lg) << "\tMenu Item: "<< endl;
           break;
       case BOOL:
           if (value.boolval == false)
-              dbglogfile << "\tBoolean value is: " << "OFF" ;
+              BOOST_LOG(lg) << "\tBoolean value is: " << "OFF" ;
           else
-              dbglogfile << "\tBoolean value is: " << "ON" ;      
-          dbglogfile << endl;
+              BOOST_LOG(lg) << "\tBoolean value is: " << "ON" ;      
+          BOOST_LOG(lg) << endl;
           break;
       case INT:
-          dbglogfile << "\tInteger value is: " << value.intval << endl;
+          BOOST_LOG(lg) << "\tInteger value is: " << value.intval << endl;
           break;
       case FLOAT:
-          dbglogfile << "\tFIXME: Float value is: " << (int)value.floatval << 
endl;
+          BOOST_LOG(lg) << "\tFIXME: Float value is: " << (int)value.floatval 
<< endl;
           break;
       case TIME:
-          dbglogfile << "\tFIXME: Time value is: " << (int)value.timeval << 
endl;
+          BOOST_LOG(lg) << "\tFIXME: Time value is: " << (int)value.timeval << 
endl;
           break;
       case EOL:
       case CLOCK:
       case ENUM:
       case DATE:
-          dbglogfile << "\tERROR: unsupported type! " << value.intval << endl;
+          BOOST_LOG(lg) << "\tERROR: unsupported type! " << value.intval << 
endl;
           break;
       default:
-          dbglogfile << "Data Type out of range";
+          BOOST_LOG(lg) << "Data Type out of range";
           break;
     };
   
   
 #if 0
     if (type == BOOL)
-        dbglogfile << "\tBoolean Value is: " << value.intval << " and is: " << 
str0[type] << "\r" << endl;
+        BOOST_LOG(lg) << "\tBoolean Value is: " << value.intval << " and is: " 
<< str0[type] << "\r" << endl;
     else
-        dbglogfile << "BOOL shit!\r\n";
+        BOOST_LOG(lg) << "BOOL shit!\r\n";
 #endif
 }
 
diff --git a/lib/msgs.cc b/lib/msgs.cc
index 0dbbfd0..5075000 100644
--- a/lib/msgs.cc
+++ b/lib/msgs.cc
@@ -96,18 +96,18 @@ Msgs::init(net_mode_e mode)
     if (mode == CLIENT) {
         _net_mode = CLIENT;
         if (createNetClient(hostname)) {
-            dbglogfile << "Connected to server at " << hostname.c_str() << 
std::endl;
+            BOOST_LOG(lg) << "Connected to server at " << hostname.c_str() << 
std::endl;
             init();                     // initialize the table of pointers
             return SUCCESS;
         } else {
-            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
+            BOOST_LOG(lg) << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
         }
     } else if (mode == DAEMON) {
         _net_mode = DAEMON;
         init(DAEMON, block);
-        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
+        BOOST_LOG(lg) << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
     } else {
-        dbglogfile << "ERROR: no mode specified! " << std::endl;
+        BOOST_LOG(lg) << "ERROR: no mode specified! " << std::endl;
         _net_mode = NONET;
     }
     return ERROR;  
@@ -129,13 +129,13 @@ Msgs::init(const std::string &hostname)
     DEBUGLOG_REPORT_FUNCTION;
   
     if (createNetClient(hostname)) {
-        dbglogfile << "Connected to server at " << hostname << std::endl;
+        BOOST_LOG(lg) << "Connected to server at " << hostname << std::endl;
         init();                     // initialize the table of pointers
         _net_mode = CLIENT;
         writeNet(heloCreate(_version));
         return SUCCESS;
     } else {
-        dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname  << std::endl;
+        BOOST_LOG(lg) << "ERROR: Couldn't create connection to server" << 
hostname  << std::endl;
     }
     return ERROR;
 }
@@ -148,18 +148,18 @@ Msgs::init(net_mode_e mode, bool block)
     if (mode == CLIENT) {
         _net_mode = CLIENT;
         if (createNetClient(hostname)) {
-            dbglogfile << "Connected to server at " << hostname.c_str() << 
std::endl;
+            BOOST_LOG(lg) << "Connected to server at " << hostname.c_str() << 
std::endl;
             init();                     // initialize the table of pointers
             return SUCCESS;
         } else {
-            dbglogfile << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
+            BOOST_LOG(lg) << "ERROR: Couldn't create connection to server" << 
hostname.c_str()  << std::endl;
         }
     } else if (mode == DAEMON) {
         _net_mode = DAEMON;
         init(true);
-        dbglogfile << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
+        BOOST_LOG(lg) << "WARNING: ignoring hostname, starting as daemon" << 
std::endl;
     } else {
-        dbglogfile << "ERROR: no mode specified! " << std::endl;
+        BOOST_LOG(lg) << "ERROR: no mode specified! " << std::endl;
         _net_mode = NONET;
     }
     return ERROR;
@@ -172,19 +172,19 @@ Msgs::init(bool block)
     _net_mode = DAEMON;
   
     if (createNetServer()) {
-        dbglogfile << "New server started for remote client." << std::endl;
+        BOOST_LOG(lg) << "New server started for remote client." << std::endl;
         init();                     // initialize the table of pointers
     } else {
-        dbglogfile << "ERROR: Couldn't create a new server" << std::endl;
+        BOOST_LOG(lg) << "ERROR: Couldn't create a new server" << std::endl;
     }      
   
     if (newNetConnection(block)) {
-        dbglogfile << "New connection started for remote client." << std::endl;
+        BOOST_LOG(lg) << "New connection started for remote client." << 
std::endl;
         _net_mode = DAEMON;
         writeNet(heloCreate(_version));
         return SUCCESS;
     } else {
-        dbglogfile << "ERROR: Couldn't create a new connection!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: Couldn't create a new connection!" << 
std::endl;
     }
     return ERROR;
 }
@@ -289,12 +289,12 @@ Msgs::cacheGet(const std:;string &name) {
             if (str.size() != 0) {
                 _body << " Has data: " << str;
             } else {
-                dbglogfile << " doesn't have data";
+                BOOST_LOG(lg) << " doesn't have data";
                 return _body.str();
             }
             return str;
         }
-        dbglogfile << "Looking for cache value for XML Tag \"" << tag
+        BOOST_LOG(lg) << "Looking for cache value for XML Tag \"" << tag
                    << "\" has " << _body.str().c_str() << std::endl;
     }
     return _body.str();
@@ -342,14 +342,14 @@ Msgs::methodGet(const std::string &name)
         } else {
             _body << " doesn't have a function pointer";
         }
-        //     dbglogfile << "Looking for method for XML Tag \"" << 
name.c_str()
+        //     BOOST_LOG(lg) << "Looking for method for XML Tag \"" << 
name.c_str()
         //                << "\" has " << _body.str().c_str() << std::endl;
         if (strcmp(str, name) == 0) {
             return ptr;
         }
     }
 #else
-    dbglogfile << "\"" << name << "\" method we want" << std::endl;
+    BOOST_LOG(lg) << "\"" << name << "\" method we want" << std::endl;
     return _methods[name];
 #endif
     //return (methodPtr_t *)0;
@@ -372,7 +372,7 @@ Msgs::methodsDump(void)
     const char         *name;
     Msgs::methodPtr_t     ptr;
   
-    dbglogfile << "We have " << (int)_methods.size() << " in function table" 
<< std::endl;
+    BOOST_LOG(lg) << "We have " << (int)_methods.size() << " in function 
table" << std::endl;
   
     std::map<const char *, Msgs::methodPtr_t>::const_iterator it;
     for (it = _methods.begin(); it != _methods.end(); it++) {
@@ -384,7 +384,7 @@ Msgs::methodsDump(void)
         } else {
             _body << "no pointer to method";
         }
-        dbglogfile << "XML Tag \"" << name
+        BOOST_LOG(lg) << "XML Tag \"" << name
                    << "\" has " << _body.str().c_str() << std::endl;
     }
 }
@@ -397,7 +397,7 @@ Msgs::cacheDump(void)
     const char         *name;
     std::string                data;
   
-    dbglogfile << "We have " << (int)_cache.size() << " items in the cache" << 
std::endl;
+    BOOST_LOG(lg) << "We have " << (int)_cache.size() << " items in the cache" 
<< std::endl;
   
     std::map<const std::string, std::string &>::const_iterator it;
     for (it = _cache.begin(); it != _cache.end(); it++) {
@@ -409,7 +409,7 @@ Msgs::cacheDump(void)
         } else {
             _body << "no data";
         }
-        dbglogfile << "XML Tag \"" << name
+        BOOST_LOG(lg) << "XML Tag \"" << name
                    << "\" has " << _body.str().c_str() << std::endl;
     }
 }
@@ -425,7 +425,7 @@ Msgs::unimplementedProcess(XMLNode *xml)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "XML tag \"" << xml->nameGet() << "\" doesn't exist." << 
std::endl;
+    BOOST_LOG(lg) << "XML tag \"" << xml->nameGet() << "\" doesn't exist." << 
std::endl;
 
     _body.str("");                // erase the current string
     _body << "<powerguru version=\"" << _version << "\">";
@@ -457,16 +457,16 @@ Msgs::process(XMLNode *xml)
     //methodsDump();
   
     if (fptr != 0) {
-        dbglogfile << "XML tag \"" << str << "\" has method pointer" << 
std::endl;
+        BOOST_LOG(lg) << "XML tag \"" << str << "\" has method pointer" << 
std::endl;
         ret = (this->*fptr)(xml);
     } else {
-        dbglogfile << "WARNING: XML tag \"" << str << "\" doesn't have a 
method pointer" << std::endl;
+        BOOST_LOG(lg) << "WARNING: XML tag \"" << str << "\" doesn't have a 
method pointer" << std::endl;
     }
 
     if (ret < 0) {
-        dbglogfile << "ERROR: Got an error from executing function pointer!" 
<< std::endl;
+        BOOST_LOG(lg) << "ERROR: Got an error from executing function 
pointer!" << std::endl;
     } else {    
-        dbglogfile << "executed function pointer successfully!" << std::endl;
+        BOOST_LOG(lg) << "executed function pointer successfully!" << 
std::endl;
     }
   
     // Process the children too
@@ -482,36 +482,36 @@ Msgs::dump(XMLNode *xml)
     int           child,  i;
     XMLNode       *childnode;
 
-    dbglogfile << "processing node " << xml->nameGet() << std::endl;
+    BOOST_LOG(lg) << "processing node " << xml->nameGet() << std::endl;
 
     // Process the node's value, if it has one.
     if (xml->valueGet() == 0) {
-        dbglogfile << "No content for node " << xml->nameGet() << std::endl;
+        BOOST_LOG(lg) << "No content for node " << xml->nameGet() << std::endl;
     } else {
-        dbglogfile << "Content for node " << xml->nameGet()
+        BOOST_LOG(lg) << "Content for node " << xml->nameGet()
                    << " is " << xml->valueGet() << std::endl;
     }
   
     // Process the attributes, if any
     if (xml->attributesSize() == 0) {
-        dbglogfile << "\tNo attributes for node " << xml->nameGet() << 
std::endl;
+        BOOST_LOG(lg) << "\tNo attributes for node " << xml->nameGet() << 
std::endl;
     } else {
         for (i=0; i<xml->attributesSize(); i++) {
-            dbglogfile << "\tAttribute is " << xml->attribGet(i)->nameGet()
+            BOOST_LOG(lg) << "\tAttribute is " << xml->attribGet(i)->nameGet()
                        << " who's value is " << xml->attribGet(i)->valueGet() 
<< std::endl;
         }
     }
 
     // Process the children, if there are any
     if (xml->childrenSize()) {
-        dbglogfile << "\tProcessing " << xml->childrenSize() << " children 
nodes for "
+        BOOST_LOG(lg) << "\tProcessing " << xml->childrenSize() << " children 
nodes for "
                    << xml->nameGet() << std::endl;
         for (child=0; child<xml->childrenSize(); child++) {
             childnode = xml->childGet(child);
             dump(childnode); // setup child node
         }
     } else {
-        dbglogfile << "Node " << xml->nameGet() << " has no children" << 
std::endl;
+        BOOST_LOG(lg) << "Node " << xml->nameGet() << " has no children" << 
std::endl;
     }
 }
 
@@ -1010,7 +1010,7 @@ Msgs::statusProcess(XMLNode &node)
     _body.str("");
     _body << _version;
 
-    // dbglogfile <<  node->valueGet() << std::endl;
+    // BOOST_LOG(lg) <<  node->valueGet() << std::endl;
   
     if (_net_mode == DAEMON) {
         if (strcmp(node->valueGet(),  "sysversion") == 0) {
@@ -1052,7 +1052,7 @@ Msgs::statusProcess(XMLNode &node)
 #endif
 
         cacheAdd(node->nameGet(), node->valueGet());
-        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << std::endl;
+        BOOST_LOG(lg) << "tag \"" << node->nameGet() << "\" has a value of: " 
<< node->valueGet() << std::endl;
     
         return SUCCESS;
     }
@@ -1064,7 +1064,7 @@ retcode_t
 Msgs::heloProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    dbglogfile << "WARNING: unimplemented method" << std::endl;
+    BOOST_LOG(lg) << "WARNING: unimplemented method" << std::endl;
   
     return ERROR;                 // FIXME: implement this method
 }
@@ -1082,7 +1082,7 @@ Msgs::metersProcess(XMLNode &node)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet()
                << " and mode is: " << (int)_net_mode << std::endl;
 
@@ -1090,7 +1090,7 @@ Msgs::metersProcess(XMLNode &node)
         //cacheDump();
         //    const unsigned char *xxx = node->nameGet();
         std::string value = cacheGet(node->valueGet());
-        dbglogfile << "value for \"" << node->valueGet() << "\" is " << 
value.c_str() << std::endl;
+        BOOST_LOG(lg) << "value for \"" << node->valueGet() << "\" is " << 
value.c_str() << std::endl;
         if (value.size() == 0) {
         } else {
       
@@ -1105,7 +1105,7 @@ Msgs::metersProcess(XMLNode &node)
     }
 
     if (_net_mode == CLIENT) {
-        //dbglogfile << node->valueGet()
+        //BOOST_LOG(lg) << node->valueGet()
         // Process the result
     }
 
@@ -1118,26 +1118,26 @@ Msgs::serverProcess(XMLNode &node)
     //  DEBUGLOG_REPORT_FUNCTION;
     XMLAttr *attr;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->hasAttributes()) {
         if ((attr = node->attribGet(0))) {
-            dbglogfile << "\tAttribute is \"" << attr->nameGet()
+            BOOST_LOG(lg) << "\tAttribute is \"" << attr->nameGet()
                        << "\" with a value of " << attr->valueGet() << 
std::endl;
             if (strcmp(attr->valueGet(), (const char *)_thisip.c_str()) != 0) {
-                dbglogfile << "WARNING: IP's don't match!!!!" << std::endl;
+                BOOST_LOG(lg) << "WARNING: IP's don't match!!!!" << std::endl;
                 return ERROR;
             }
         }
     }
 
     if (strcmp(node->valueGet(), (const char *)_thishost.c_str()) != 0) {
-        dbglogfile << "WARNING: Host's don't match!!!!" << std::endl;
+        BOOST_LOG(lg) << "WARNING: Host's don't match!!!!" << std::endl;
         return ERROR;
     }
 
-    dbglogfile << "Host and IP data match" << std::endl;
+    BOOST_LOG(lg) << "Host and IP data match" << std::endl;
     return SUCCESS;
 }
 
@@ -1147,16 +1147,16 @@ Msgs::clientProcess(XMLNode &node)
     // DEBUGLOG_REPORT_FUNCTION;
     XMLAttr *attr;
 
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (_remoteip.size() > 0) {
         if (node->hasAttributes()) {
             if ((attr = node->attribGet(0))) {
-                dbglogfile << "\tAttribute is \"" << attr->nameGet()
+                BOOST_LOG(lg) << "\tAttribute is \"" << attr->nameGet()
                            << "\" with a value of " << attr->valueGet() << 
std::endl;
                 if (strcmp(attr->valueGet(), (const char *)_remoteip.c_str()) 
!= 0) {
-                    dbglogfile << "WARNING: IP's don't match!!!!" << std::endl;
+                    BOOST_LOG(lg) << "WARNING: IP's don't match!!!!" << 
std::endl;
                     return ERROR;
                 }
             }
@@ -1165,7 +1165,7 @@ Msgs::clientProcess(XMLNode &node)
 
     if (_remotehost.size() != 0) {
         if (strcmp(node->valueGet(), (const char *)_remotehost.c_str()) != 0) {
-            dbglogfile << "WARNING: Host's don't match!!!!" << std::endl;
+            BOOST_LOG(lg) << "WARNING: Host's don't match!!!!" << std::endl;
             return ERROR;
         }
     }
@@ -1183,17 +1183,17 @@ Msgs::powerguruProcess(XMLNode &node)
     _body.str("");
     _body << _version;
   
-//   dbglogfile << "Node is \"" << node->nameGet()
+//   BOOST_LOG(lg) << "Node is \"" << node->nameGet()
 //              << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->hasAttributes()) {
         if ((attr = node->attribGet(0))) {
-//       dbglogfile << "\tAttribute is \"" << attr->nameGet().c_str()
+//       BOOST_LOG(lg) << "\tAttribute is \"" << attr->nameGet().c_str()
 //                  << "\" with a value of " << attr->valueGet().c_str() << 
std::endl;
             if (strcmp((const char *)_body.str().c_str(), (const 
char*)attr->valueGet()) != 0) {
-                dbglogfile << "Versions in header don't match!" << std::endl;
+                BOOST_LOG(lg) << "Versions in header don't match!" << 
std::endl;
             } else {
-                dbglogfile << "Versions in header match" << std::endl;
+                BOOST_LOG(lg) << "Versions in header match" << std::endl;
             }
         }
     }
@@ -1205,11 +1205,11 @@ retcode_t
 Msgs::chargeAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1220,16 +1220,16 @@ retcode_t
 Msgs::loadAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         //    return ERROR;
     }
   
     if (_net_mode == CLIENT) {
-        dbglogfile << "Battery voltage is: " << node->valueGet() << std::endl;
+        BOOST_LOG(lg) << "Battery voltage is: " << node->valueGet() << 
std::endl;
     
         return SUCCESS;
     }
@@ -1249,11 +1249,11 @@ retcode_t
 Msgs::pvAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1264,11 +1264,11 @@ retcode_t
 Msgs::pvVoltsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1279,11 +1279,11 @@ retcode_t
 Msgs::dailyKwhProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1294,11 +1294,11 @@ retcode_t
 Msgs::hertzProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1309,16 +1309,16 @@ retcode_t
 Msgs::batteryVoltsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-//   dbglogfile << "Node is \"" << node->nameGet()
+//   BOOST_LOG(lg) << "Node is \"" << node->nameGet()
 //              << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         //    return ERROR;
     }
 
     if (_net_mode == CLIENT) {
-        dbglogfile << "Battery voltage is: " << node->valueGet() << std::endl;
+        BOOST_LOG(lg) << "Battery voltage is: " << node->valueGet() << 
std::endl;
     
         return SUCCESS;
     }
@@ -1338,11 +1338,11 @@ retcode_t
 Msgs::buyAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1353,11 +1353,11 @@ retcode_t
 Msgs::sellAmpsProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1368,11 +1368,11 @@ retcode_t
 Msgs::acVoltsOutProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1383,11 +1383,11 @@ retcode_t
 Msgs::ac1InProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1398,11 +1398,11 @@ retcode_t
 Msgs::ac2InProcess(XMLNode &node) {
     DEBUGLOG_REPORT_FUNCTION;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
       
@@ -1431,18 +1431,18 @@ Msgs::commandProcess(XMLNode &node)
     DEBUGLOG_REPORT_FUNCTION;
     std::string str;
   
-    dbglogfile << "Node is \"" << node->nameGet()
+    BOOST_LOG(lg) << "Node is \"" << node->nameGet()
                << "\" with a value of " << node->valueGet() << std::endl;
       
     if (node->valueGet() <= 0) {
-        dbglogfile << "ERROR: no value in messages!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: no value in messages!" << std::endl;
         return ERROR;
     }
 
     _body.str("");
     _body << _version;
 
-    // dbglogfile <<  node->valueGet() << std::endl;
+    // BOOST_LOG(lg) <<  node->valueGet() << std::endl;
 
     if (_net_mode == DAEMON) {
         if (strcmp(node->valueGet(), "auxilary") == 0) {
@@ -1454,7 +1454,7 @@ Msgs::commandProcess(XMLNode &node)
         } else if (strcmp(node->valueGet(), "") == 0) {
             str = responseCreate(COMMAND, node->valueGet(), "charger");
         } else {
-            dbglogfile << "VALUEGET: " << node->valueGet() << std::endl;
+            BOOST_LOG(lg) << "VALUEGET: " << node->valueGet() << std::endl;
             str = responseCreate(RESPONSE, node->valueGet(), "foobar");
         }
         if (writeNet(str + "\r\n")) {
@@ -1469,7 +1469,7 @@ Msgs::commandProcess(XMLNode &node)
             return SUCCESS;
         }
         cacheAdd(node->nameGet(), node->valueGet());
-        dbglogfile << "tag \"" << node->nameGet() << "\" has a value of: " << 
node->valueGet() << std::endl;
+        BOOST_LOG(lg) << "tag \"" << node->nameGet() << "\" has a value of: " 
<< node->valueGet() << std::endl;
     
         return SUCCESS;
     }
diff --git a/lib/postgresql.cc b/lib/postgresql.cc
index aaab241..f20c0d3 100644
--- a/lib/postgresql.cc
+++ b/lib/postgresql.cc
@@ -28,8 +28,6 @@
 #include <cstdio>
 #include <sstream>
 
-using namespace std;
-
 #include "database.h"
 #include "log.h"
 
@@ -41,7 +39,6 @@ using namespace std;
 
 const int LINELEN = 80;
 const int QUERYLEN = 10000;
-extern LogFile dbglogfile;
 
 Database::Database()
     : _dbtype(NODB), _dbport(0)
@@ -94,15 +91,15 @@ Database::openDB (void)
 
     unsigned long flag = 0;
 
-    dbglogfile <<"Connecting to Postgresql database "  << _dbname.c_str()
+    BOOST_LOG(lg) <<"Connecting to Postgresql database "  << _dbname.c_str()
                << " on " << _dbhost.c_str()
-               << " as user " << _dbuser.c_str() << endl;
+               << " as user " << _dbuser.c_str();
 
     _connection = PQconnectdb("dbname = powerguru");
      /* Check to see that the backend connection was successfully made */
     if (PQstatus(_connection) != CONNECTION_OK)
     {
-        dbglogfile << "ERROR: Connection to database failed" << std::endl;
+        BOOST_LOG(lg) << "ERROR: Connection to database failed";
         //exit_nicely(_connection);
     }
 
@@ -128,10 +125,10 @@ Database::queryInsert(const std::string &query)
     std::string str = "INSERT INTO onewire VALUES(";
     str += query + ");";
 
-    //dbglogfile << "Query is: " << query << endl;
+    BOOST_LOG(lg) << "Query is: " << query;
     
     if (PQexec(_connection, str.c_str()) == nullptr) {
-        std::cerr << "Lost connection to the database server, shutting 
down..." << endl;
+        std::cerr << "Lost connection to the database server, shutting 
down...";
         std::cerr << PQerrorMessage(_connection) << std::endl;
     }
     
@@ -149,7 +146,7 @@ Database::queryResults(const char *query)
     int         nrows;
     unsigned int i, res;
 
-    dbglogfile << "Query is: " << query << endl;
+    BOOST_LOG(lg) << "Query is: " << query;
 
     // FIXME: return something intelligent here
     return (void *)0;
@@ -169,7 +166,7 @@ Database::queryInsert(vector<meter_data_t *> data)
     ostringstream  query;
 
     if (data.size() == 0) {
-        dbglogfile << "No data to insert." << endl;
+        BOOST_LOG(lg) << "No data to insert.";
         return false;
     }
   
diff --git a/lib/rc.cc b/lib/rc.cc
index 9f31fd3..1264b4a 100644
--- a/lib/rc.cc
+++ b/lib/rc.cc
@@ -32,7 +32,6 @@
 #include "log.h"
 #include "rc.h"
 
-using namespace std;
 using namespace rcinit;
   
 RCinitFile::RCinitFile()
@@ -48,7 +47,7 @@ retcode_t
 RCinitFile::load_files()
 {
     char *home;
-    string loadfile;
+    std::string loadfile;
   
     // Check the default system location
     loadfile = "/etc/powerguru/config";
@@ -71,15 +70,15 @@ RCinitFile::load_files()
 
 // Parse the config file and set the variables.
 retcode_t
-RCinitFile::parse_file(string filespec)
+RCinitFile::parse_file(std::string &filespec)
 {
     struct stat stats;
-    string action;
-    string variable;
-    string value;
-    ifstream in;
+    std::string action;
+    std::string variable;
+    std::string value;
+    std::ifstream in;
 
-    dbglogfile << "Seeing if " << filespec << " exists." << endl;
+    BOOST_LOG(lg) << "Seeing if " << filespec << " exists.";
     if (filespec.size() == 0) {
         return ERROR;
     }
@@ -88,7 +87,7 @@ RCinitFile::parse_file(string filespec)
         in.open(filespec.c_str());
     
         if (!in) {
-            dbglogfile << "ERROR: Couldn't open file: " << filespec << endl;
+            BOOST_LOG(lg) << "ERROR: Couldn't open file: " << filespec;
             return ERROR;
         }
 
@@ -98,36 +97,36 @@ RCinitFile::parse_file(string filespec)
             in >> action;
             // Ignore comment lines
             if (action == "#" ) {
-                dbglogfile << "Ignoring comment line " << endl;
+                BOOST_LOG(lg) << "Ignoring comment line ";
                 continue;
             }
       
             in >> variable >> value;
-            //      dbglogfile << action << variable << value << endl;
+            //      BOOST_LOG(lg) << action << variable << value;
 
             if (action == "set") {
                 if (variable == "dbhost") {
-                    dbglogfile << "Database host configured to be " << value 
<< endl;
+                    BOOST_LOG(lg) << "Database host configured to be " << 
value;
                     _dbhost = value;
                 }
                 if (variable == "dbuser") {
-                    dbglogfile << "Database user configured to be " << value 
<< endl;
+                    BOOST_LOG(lg) << "Database user configured to be " << 
value;
                     _dbuser = value;
                 }
                 if (variable == "dbpasswd") {
-                    dbglogfile << "Database password configured to be " << 
value << endl;
+                    BOOST_LOG(lg) << "Database password configured to be " << 
value;
                     _dbpasswd = value;
                 }
                 if (variable == "dbname") {
-                    dbglogfile << "Database name configured to be " << value 
<< endl;
+                    BOOST_LOG(lg) << "Database name configured to be " << 
value;
                     _dbname = value;
                 }
                 if (variable == "devmode") {
-                    dbglogfile << "Device mode configured to be " << value << 
endl;
+                    BOOST_LOG(lg) << "Device mode configured to be " << value;
                     _devmode = value;
                 }
                 if (variable == "device") {
-                    dbglogfile << "Device is " << value << endl;
+                    BOOST_LOG(lg) << "Device is " << value;
                     _device = value;
                 }
             }
@@ -147,9 +146,9 @@ RCinitFile::parse_file(string filespec)
 
 // Write the changed settings to the config file
 retcode_t
-RCinitFile::update_file(string filespec)
+RCinitFile::update_file(std::string &filespec)
 {
-    cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
+    std::cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << std::endl;
     return ERROR;
 }
 
diff --git a/lib/rc.h b/lib/rc.h
index 33bd893..1955ccb 100644
--- a/lib/rc.h
+++ b/lib/rc.h
@@ -35,8 +35,8 @@ public:
     RCinitFile();
     ~RCinitFile();
     retcode_t load_files();
-    retcode_t parse_file(std::string filespec);
-    retcode_t update_file(std::string filespec);
+    retcode_t parse_file(std::string &filespec);
+    retcode_t update_file(std::string &filespec);
 
     // Database config options
     std::string dbhostGet()   { return _dbhost; }
diff --git a/lib/sharedlib.cc b/lib/sharedlib.cc
index e24fb68..537ee33 100644
--- a/lib/sharedlib.cc
+++ b/lib/sharedlib.cc
@@ -53,7 +53,7 @@ SharedLib::OpenLib (string &filespec, ErrCond &Err)
           case EBADF:
           case ENOENT:
               Err.SetMsg("Specified shared library doesn't exist");
-              dbglogfile << "ERROR: Dynamic library, " << filespec << " 
doesn't exist!" << endl;
+              BOOST_LOG(lg) << "ERROR: Dynamic library, " << filespec << " 
doesn't exist!" << endl;
               return ERROR;
               break;
         }
@@ -78,7 +78,7 @@ SharedLib::OpenLib (string &filespec, ErrCond &Err)
         return ERROR;
     }
 
-    dbglogfile << "Initialized ltdl" << endl;
+    BOOST_LOG(lg) << "Initialized ltdl" << endl;
   
     // Get the path to look for libraries in, or force a default one 
     // if the ABELMON environment variable isn't set.
@@ -86,7 +86,7 @@ SharedLib::OpenLib (string &filespec, ErrCond &Err)
     if (abelmon == NULL) {
         getcwd((char *)&pwd, 512);
         abelmon = pwd;
-        dbglogfile << "WARNING: using default DL search path" << endl;
+        BOOST_LOG(lg) << "WARNING: using default DL search path" << endl;
     }
   
     errors = lt_dladdsearchdir (abelmon);
@@ -95,9 +95,9 @@ SharedLib::OpenLib (string &filespec, ErrCond &Err)
         return ERROR;
     }
 
-    dbglogfile << "Added " << abelmon << " to the search paths" << endl;
+    BOOST_LOG(lg) << "Added " << abelmon << " to the search paths" << endl;
   
-    dbglogfile << "Trying to open shared library " << filespec << endl;
+    BOOST_LOG(lg) << "Trying to open shared library " << filespec << endl;
 
     dlhandle = lt_dlopenext (filespec.c_str());
 
@@ -108,7 +108,7 @@ SharedLib::OpenLib (string &filespec, ErrCond &Err)
 
     dlname = filespec;
   
-    dbglogfile << "Opened dynamic library " << filespec << endl;
+    BOOST_LOG(lg) << "Opened dynamic library " << filespec << endl;
     return SUCCESS;
 }
 
@@ -126,7 +126,7 @@ SharedLib::GetSymbol (std::string &symbol, ErrCond &err)
         err << "Couldn't find symbol" << symbol << endl;
         return NULL;
     } else {
-        dbglogfile << "Found symbol " << symbol << " @ " << (void *)run << 
endl;
+        BOOST_LOG(lg) << "Found symbol " << symbol << " @ " << (void *)run << 
endl;
     }
 
     return run;
@@ -155,11 +155,11 @@ SharedLib::ScanDir (void) {
     const char *abelmon = (char *)getenv ("ABELMON");
     if (abelmon == NULL) {
         abelmon = "/usr/local/lib/abelmon";
-        dbglogfile << "ERROR: You need to set ABELMON" << endl;
+        BOOST_LOG(lg) << "ERROR: You need to set ABELMON" << endl;
     }
   
     lt_dladdsearchdir (abelmon);
-    // dbglogfile << timestamp << "Searching in " << abelmon << "for database 
drivers" << endl;
+    // BOOST_LOG(lg) << timestamp << "Searching in " << abelmon << "for 
database drivers" << endl;
   
     DIR *library_dir = opendir (abelmon);
 
@@ -184,11 +184,11 @@ SharedLib::ScanDir (void) {
         //    InitDBaddr = (retcode_t (*)(...))dlsym (handle, "InitDB");
         (lt_ptr_t) InitDBaddr = lt_dlsym (dlhandle, "InitDB");
         if (InitDBaddr != NULL) {
-            //      dbglogfile << "Found OpenDB in " << entry->d_name << endl;
+            //      BOOST_LOG(lg) << "Found OpenDB in " << entry->d_name << 
endl;
             cout << "Found InitDB in " << entry->d_name << " at " << addr << 
endl;
             InitDBaddr();
         } else {
-            //      dbglogfile << "Didn't find OpenDB in " << entry->d_name << 
endl;
+            //      BOOST_LOG(lg) << "Didn't find OpenDB in " << entry->d_name 
<< endl;
             cout << "Didn't find InitDB in " << entry->d_name << endl;
         }
         lt_dlclose (dlhandle);
diff --git a/lib/tcpip.cc b/lib/tcpip.cc
index 2e1a2d0..32e145f 100644
--- a/lib/tcpip.cc
+++ b/lib/tcpip.cc
@@ -49,8 +49,6 @@ static const int INBUF          = 2048;
 static const int DEFAULTTIMEOUT = 5;
 const int BLOCKING_TIMEOUT      = -1;
 
-extern LogFile dbglogfile;
-
 #ifndef INADDR_NONE
 #define INADDR_NONE  0xffffffff
 #endif
@@ -83,8 +81,8 @@ Tcpip::createNetServer(const std::string &service, const 
std::string &proto)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
-    dbglogfile << "Port number is " << _service->s_port
-               << ", byte swapped is " << htons(_service->s_port) << std::endl;
+    BOOST_LOG(lg) << "Port number is " << _service->s_port
+               << ", byte swapped is " << htons(_service->s_port);
 
     // Store the port number
     _port = _service->s_port;
@@ -119,9 +117,9 @@ Tcpip::createNetServer(short port, const std::string 
&protocol)
     }
     
     if (bind(_sockIOfd, addr->ai_addr, addr->ai_addrlen) == -1) {
-        dbglogfile << "WARNING: unable to bind to"
+        BOOST_LOG(lg) << "WARNING: unable to bind to"
                    << inet_ntoa(sock_in.sin_addr)
-                   << " port!" << strerror(errno) << std::endl;
+                   << " port!" << strerror(errno);
         if (errno == EADDRINUSE) {
             std::cerr << "ERROR: There is another process already bound to 
this port!"
                       << std::endl;
@@ -129,17 +127,17 @@ Tcpip::createNetServer(short port, const std::string 
&protocol)
         }
     }
     
-    dbglogfile << "Server bound to port: " << port
+    BOOST_LOG(lg) << "Server bound to port: " << port
                << " on IP " << inet_ntoa(((struct sockaddr_in 
*)addr->ai_addr)->sin_addr)
-                   << " using fd #" << _sockIOfd << std::endl;
+                   << " using fd #" << _sockIOfd;
     
     if (listen(_sockIOfd, 5) < 0) {
-        dbglogfile << "ERROR: unable to listen on port: "
-                   << port << ": " <<  strerror(errno) << std::endl; 
+        BOOST_LOG(lg) << "ERROR: unable to listen on port: "
+                   << port << ": " <<  strerror(errno); 
         return ERROR;
     }
     
-    dbglogfile << "Listening for net traffic on fd #" << _sockIOfd << 
std::endl;
+    BOOST_LOG(lg) << "Listening for net traffic on fd #" << _sockIOfd;
 
     return SUCCESS;
 }
@@ -165,7 +163,7 @@ Tcpip::newNetConnection(bool block)
     fd_set          fdset;
     int             retries = 3;
 
-    dbglogfile << "Trying to accept net traffic on fd #" << _sockIOfd << 
std::endl;
+    BOOST_LOG(lg) << "Trying to accept net traffic on fd #" << _sockIOfd;
   
     if (_sockIOfd <= 2) {
         return ERROR;
@@ -190,30 +188,30 @@ Tcpip::newNetConnection(bool block)
         }
     
         if (FD_ISSET(0, &fdset)) {
-            dbglogfile << "There is data at the console for stdin!" << 
std::endl;
+            BOOST_LOG(lg) << "There is data at the console for stdin!";
             return SUCCESS;
         }
 
         // If interupted by a system call, try again
         if (ret == -1 && errno == EINTR) {
-            dbglogfile <<
+            BOOST_LOG(lg) <<
                 "The accept() socket for fd #%d was interupted by a system 
call!"
-                       << _sockIOfd << std::endl;
+                       << _sockIOfd;
         }
     
         if (ret == -1) {
-            dbglogfile << "ERROR: The accept() socket for fd " << _sockIOfd
-                       << " never was available for writing!" << std::endl;
+            BOOST_LOG(lg) << "ERROR: The accept() socket for fd " << _sockIOfd
+                       << " never was available for writing!";
             return ERROR;
         }
     
         if (ret == 0) {
-            dbglogfile <<
+            BOOST_LOG(lg) <<
                 "ERROR: The accept() socket for fd #%d timed out waiting to 
write!"
-                       << _sockIOfd << std::endl;
+                       << _sockIOfd;
         }
         if (ret >= 1) {
-            dbglogfile << "The accept() socket got something!" << std::endl;
+            BOOST_LOG(lg) << "The accept() socket got something!";
         }
     }
 #endif
@@ -223,10 +221,10 @@ Tcpip::newNetConnection(bool block)
     _sockfd = ::accept(_sockIOfd, &fsin, &alen);
   
     if (_sockfd < 0) {
-        dbglogfile << "ERROR: unable to accept : " << strerror(errno) << 
std::endl;
+        BOOST_LOG(lg) << "ERROR: unable to accept : " << strerror(errno);
         return ERROR;
     } else {
-        dbglogfile << "Accepting tcp/ip connection on fd #" << _sockfd << 
std::endl;
+        BOOST_LOG(lg) << "Accepting tcp/ip connection on fd #" << _sockfd;
     }
 
     std::memcpy(&_client, &fsin, sizeof(struct sockaddr));
@@ -261,15 +259,15 @@ Tcpip::createNetClient(const std::string &hostname, short 
port,
     if (addr) {
         _sockfd = ::socket(addr->ai_family, addr->ai_socktype, 
_proto->p_proto);
         if (_sockfd < 0) {
-            dbglogfile << "WARNING: unable to create socket: "
-                       << ::strerror(errno) << std::endl;
+            BOOST_LOG(lg) << "WARNING: unable to create socket: "
+                       << ::strerror(errno);
             return ERROR;
         }
 
-        dbglogfile << "Trying to connect to: " << hostname << ":" << port << 
std::endl;
+        BOOST_LOG(lg) << "Trying to connect to: " << hostname << ":" << port;
         if (::connect(_sockfd, addr->ai_addr, addr->ai_addrlen) < 0) {
-            dbglogfile << "ERROR: Couldn't connect to: " << hostname << " "
-                       << strerror(errno) << std::endl;
+            BOOST_LOG(lg) << "ERROR: Couldn't connect to: " << hostname << " "
+                       << strerror(errno);
             retries = 1;
             while (retries-- > 0) {
                 // We use select to wait for the read file descriptor to be
@@ -283,37 +281,37 @@ Tcpip::createNetClient(const std::string &hostname, short 
port,
                 ret = ::select(_sockfd+1, &fdset, NULL, NULL, &tval);
                 // If interupted by a system call, try again
                 if (ret == -1 && errno == EINTR) {
-                    dbglogfile <<
+                    BOOST_LOG(lg) <<
                         "The connect() socket for fd #%d was interupted by a 
system call!"
-                               << _sockfd << std::endl;
+                               << _sockfd;
                 }
                 if (ret == -1) {
-                    dbglogfile <<
+                    BOOST_LOG(lg) <<
                         "The connect() socket for fd #%d never was available 
for writing!"
-                               << _sockfd << std::endl;
+                               << _sockfd;
                     shutdown(_sockfd, SHUT_RDWR);
                     return ERROR;
                 }
                 if (ret == 0) {
-                    dbglogfile <<
+                    BOOST_LOG(lg) <<
                         "WARNING: The connect() socket for fd #%d timed out 
waiting to write!"
-                               << _sockfd << std::endl;
+                               << _sockfd;
                 }
             }
             ret = ::connect(_sockfd, addr->ai_addr, addr->ai_addrlen);
             if (ret <= 0) {
-                dbglogfile << "unable to connect to "
+                BOOST_LOG(lg) << "unable to connect to "
                            << hostname
                            << ", port " << port
-                           << ": " << strerror(errno) << std::endl;
+                           << ": " << strerror(errno);
                 close(_sockfd);
                 return ERROR;
             }
             if (ret <= 0) {
-                dbglogfile << "unable to connect to "
+                BOOST_LOG(lg) << "unable to connect to "
                            << hostname
                            << ", port " << port
-                           << ": " << strerror(errno) << std::endl;
+                           << ": " << strerror(errno);
                 close(_sockfd);
                 return ERROR;
             }
@@ -324,9 +322,9 @@ Tcpip::createNetClient(const std::string &hostname, short 
port,
     char ascip[INET_ADDRSTRLEN];
     std::memset(ascip, 0, INET_ADDRSTRLEN);
     //inet_ntop(AF_INET, &_ipaddr, ascip, INET_ADDRSTRLEN);
-    dbglogfile << "Client connected to service at port " << port
+    BOOST_LOG(lg) << "Client connected to service at port " << port
                << " at IP " << ascip
-               << " using fd #" << _sockfd << std::endl;
+               << " using fd #" << _sockfd;
   
     // For a client, the IO file descriptor is the same as the default one
     _sockIOfd = _sockfd;
@@ -370,23 +368,23 @@ Tcpip::closeNet(void)
 #if 0
             if (shutdown(_sockfd, SHUT_RDWR) < 0) {
                 if (errno != ENOTCONN) {
-                    dbglogfile << "WARNING: Unable to shutdown socket for fd #"
-                               << _sockfd << strerror(errno) << std::endl;
+                    BOOST_LOG(lg) << "WARNING: Unable to shutdown socket for 
fd #"
+                               << _sockfd << strerror(errno);
                 } else {
-                    dbglogfile << "The socket using fd #" << _sockfd
-                               << " has been shut down successfully." << 
std::endl;
+                    BOOST_LOG(lg) << "The socket using fd #" << _sockfd
+                               << " has been shut down successfully.";
                     return SUCCESS;
                 }
             }
 #endif 
             if (close(_sockfd) < 0) {
-                dbglogfile <<
+                BOOST_LOG(lg) <<
                     "WARNING: Unable to close the socket for fd "
-                           <<  _sockfd << strerror(errno) << std::endl;
+                           <<  _sockfd << strerror(errno);
                 sleep(1);
                 retries++;
             } else {
-                // dbglogfile << "Closed the socket for "
+                // BOOST_LOG(lg) << "Closed the socket for "
                 //            << (_service->s_name
                 //            << " on fd " << _sockfd << std::endl;
                 return SUCCESS;
@@ -442,21 +440,21 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
 
         // If interupted by a system call, try again
         if (ret == -1 && (errno == EINTR || errno == EAGAIN)) {
-            dbglogfile << "The socket for fd #%d was interupted by a system 
call!"
-                       << fd << std::endl;
+            BOOST_LOG(lg) << "The socket for fd #%d was interupted by a system 
call!"
+                       << fd;
             continue;
         }
         if (ret == 0) {
-            dbglogfile << "There is no data in the socket for fd #" << fd << 
std::endl;
+            BOOST_LOG(lg) << "There is no data in the socket for fd #" << fd;
             // msgs.clear();
             return SUCCESS;
         }
         if (ret == -1) {
-            dbglogfile << "The socket for fd #%d never was available!" << fd 
<< std::endl;
+            BOOST_LOG(lg) << "The socket for fd #%d never was available!" << 
fd;
             return ERROR;
         }
         if (ret > 0) {
-            dbglogfile << "There is data in the socket for fd #" << fd << 
std::endl;
+            BOOST_LOG(lg) << "There is data in the socket for fd #" << fd;
         }
 
         memset(buf, 0, INBUF);
@@ -481,8 +479,8 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
             return ERROR;
         }
         cr = strlen(buf);
-        //dbglogfile << "read " << ret << " bytes, first msg terminates at " 
<< cr << std::endl;
-        //dbglogfile << "read " << buf << std::endl;
+        //BOOST_LOG(lg) << "read " << ret << " bytes, first msg terminates at 
" << cr << std::endlen;
+        //BOOST_LOG(lg) << "read " << buf << std::endl;
         ptr = buf;
         // If we get a single XML message, do less work
         if (ret == cr + 1) {
@@ -530,7 +528,7 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
                 memset(packet, 0, adjusted_size);
                 strcpy(packet, ptr);
                 ptr += cr + 1;
-                //dbglogfile << "Packet is: " << packet << std::endl;
+                //BOOST_LOG(lg) << "Packet is: " << packet << std::endl;
             } // end of if remainder
             if (*packet == '<') {
                 eom = strrchr(packet, '\n'); // drop the CR off the end there 
is one
@@ -543,11 +541,11 @@ Tcpip::anydata(int fd, std::vector<const unsigned char *> 
&msgs)
                 msgs.push_back((const unsigned char *)packet);
             } else {
                 if (*packet == *ptr) {
-                    // dbglogfile << "Read all XML messages in packet " << 
packet << std::endl;
+                    // BOOST_LOG(lg) << "Read all XML messages in packet " << 
packet << std::endl;
                     break;
                 } else { 
-                    //dbglogfile << "WARNING: Throwing out partial packet " << 
std::endl;
-                    dbglogfile << "WARNING: Throwing out partial packet " << 
packet << std::endl;
+                    //BOOST_LOG(lg) << "WARNING: Throwing out partial packet " 
<< std::endl;
+                    BOOST_LOG(lg) << "WARNING: Throwing out partial packet " 
<< packet;
                     break;
                 }
             }
@@ -590,8 +588,8 @@ Tcpip::readNet(std::vector<unsigned char> &buf)
         FD_ZERO(&fdset);
         FD_SET(_sockfd, &fdset);
     } else {
-        dbglogfile << "WARNING: Can't do anything with socket fd #"
-                   << _sockfd << std::endl;
+        BOOST_LOG(lg) << "WARNING: Can't do anything with socket fd #"
+                   << _sockfd;
         buf.clear();
         buf.push_back(255);
         return buf;
@@ -614,30 +612,28 @@ Tcpip::readNet(std::vector<unsigned char> &buf)
 
     // If interupted by a system call, try again
     if (ret == -1 && errno == EINTR) {
-        dbglogfile <<
-            "The socket for fd #" << _sockfd << " we interupted by a system 
call!"
-                                  << std::endl;
-        dbglogfile << "WARNING: error is " << strerror(errno) << std::endl;
+        BOOST_LOG(lg) <<
+            "The socket for fd #" << _sockfd << " we interupted by a system 
call!";
+        BOOST_LOG(lg) << "WARNING: error is " << strerror(errno);
     }
   
     if (ret == -1) {
-        dbglogfile << "The socket for fd #" << _sockfd << " never was 
available for reading!"
-                   << std::endl;
+        BOOST_LOG(lg) << "The socket for fd #" << _sockfd << " never was 
available for reading!";
     }
   
 #if 0                           // FIXME: too verbose
     if (ret == 0) {
-        dbglogfile <<
-            "The socket for fd #" << _sockfd << " timed out waiting to read!" 
<< std::endl;
+        BOOST_LOG(lg) <<
+            "The socket for fd #" << _sockfd << " timed out waiting to read!";
     }
 #endif
     ret = read(_sockfd, buffer, nbytes);
 #if 0
     if (ret != 0) {
-        dbglogfile << "Read " << ret << " bytes from fd #" << _sockfd << 
std::endl;
-        dbglogfile << "Buffer says " << buffer << std::endl;
-        dbglogfile << "Read " << (int)buf.size() << " bytes from fd #" << 
_sockfd << std::endl;
-        dbglogfile << "Buffer says " << buf.data() << std::endl;
+        BOOST_LOG(lg) << "Read " << ret << " bytes from fd #" << _sockfd;
+        BOOST_LOG(lg) << "Buffer says " << buffer << std::endl;
+        BOOST_LOG(lg) << "Read " << (int)buf.size() << " bytes from fd #" << 
_sockfd;
+        BOOST_LOG(lg) << "Buffer says " << buf.data();
     }
 #endif
 
@@ -655,7 +651,7 @@ Tcpip::writeNet(const std::string &buffer) {
 int
 Tcpip::writeNet(const std::vector<unsigned char> &buffer)
 {
-     DEBUGLOG_REPORT_FUNCTION;
+//     DEBUGLOG_REPORT_FUNCTION;
     fd_set              fdset;
     int                 ret = 0;
     const unsigned char *bufptr;
@@ -665,7 +661,7 @@ Tcpip::writeNet(const std::vector<unsigned char> &buffer)
     bufptr = buffer.data();
     int nbytes = buffer.size();
 
-    dbglogfile << "Writing data to socket." << std::endl;
+    BOOST_LOG(lg) << "Writing data to socket.";
 
     while (retries-- > 1) {
         // Wait for the socket to be ready for writing
@@ -673,8 +669,8 @@ Tcpip::writeNet(const std::vector<unsigned char> &buffer)
             FD_ZERO(&fdset);
             FD_SET(_sockfd, &fdset);
         } else {
-            dbglogfile << "WARNING: Can't do anything with socket fd #!"
-                       << _sockfd << std::endl;
+            BOOST_LOG(lg) << "WARNING: Can't do anything with socket fd #!"
+                       << _sockfd;
             return -1;
         }
     
@@ -685,19 +681,19 @@ Tcpip::writeNet(const std::vector<unsigned char> &buffer)
     
         // If interupted by a system call, try again
         if (ret == -1 && errno == EINTR) {
-            dbglogfile <<
-                "The socket for fd #" << _sockfd << " we interupted by a 
system call!" << std::endl;
+            BOOST_LOG(lg) <<
+                "The socket for fd #" << _sockfd << " we interupted by a 
system call!";
         }
     
         if (ret == -1) {
-            dbglogfile << "The socket for fd #" << _sockfd
-                       << " never was available for writing!" << std::endl;
+            BOOST_LOG(lg) << "The socket for fd #" << _sockfd
+                       << " never was available for writing!";
             continue;
         }
     
         if (ret == 0) {
-            dbglogfile << "The socket for fd #"
-                       << _sockfd << " timed out waiting to write!" << 
std::endl;
+            BOOST_LOG(lg) << "The socket for fd #"
+                       << _sockfd << " timed out waiting to write!";
             continue;
         }
         ret = write(_sockfd, bufptr, nbytes);
@@ -706,31 +702,31 @@ Tcpip::writeNet(const std::vector<unsigned char> &buffer)
     
     
         if (ret == 0) {
-            dbglogfile << "Couldn't write any bytes to fd #" << _sockfd << 
std::endl;
+            BOOST_LOG(lg) << "Couldn't write any bytes to fd #" << _sockfd;
             return ret;
         }
     
         if (ret < 0) {
-            dbglogfile << "Couldn't write " << nbytes << " bytes to fd #"
-                       << _sockfd << std::endl;
+            BOOST_LOG(lg) << "Couldn't write " << nbytes << " bytes to fd #"
+                       << _sockfd;
             return ret;
         }
     
         if (ret > 0) {
             bufptr += ret;            
             if (ret != nbytes) {
-                dbglogfile << "wrote " << ret << " bytes to fd #"
-                           << _sockfd << " expected " <<  nbytes << std::endl;
+                BOOST_LOG(lg) << "wrote " << ret << " bytes to fd #"
+                           << _sockfd << " expected " <<  nbytes;
                 retries++;
             } else {
 #if 0
-                dbglogfile << "Wrote " << ret << " bytes to fd #" << _sockfd 
<< std::endl;
+                BOOST_LOG(lg) << "Wrote " << ret << " bytes to fd #" << 
_sockfd;
 #endif
                 return ret;
             }
       
             if (ret == 0) {
-                dbglogfile << "Wrote 0 bytes to fd #" << _sockfd << std::endl;
+                BOOST_LOG(lg) << "Wrote 0 bytes to fd #" << _sockfd << 
std::endl;
             }
         }
     }
diff --git a/lib/tcpip.h b/lib/tcpip.h
index 5d80858..d67af8a 100644
--- a/lib/tcpip.h
+++ b/lib/tcpip.h
@@ -32,7 +32,6 @@
 #include <vector>
 #include <sys/ioctl.h>
 
-#include "log.h"
 #include "tcputil.h"
 
 extern const std::string DEFAULTPROTO;
@@ -41,8 +40,8 @@ extern const short DEFAULTPORT;
 class Tcpip : public Tcputil
 {
 public:
-    Tcpip();
-    ~Tcpip();
+    Tcpip(void);
+    ~Tcpip(void);
 
     // Create a new server. After creating it, then you have to wait for an
     // incoming connection.
diff --git a/lib/tcputil.cc b/lib/tcputil.cc
index 5e256a7..5062094 100644
--- a/lib/tcputil.cc
+++ b/lib/tcputil.cc
@@ -38,9 +38,6 @@
 #include "tcputil.h"
 #include "tcpip.h"
 #include "log.h"
-#include "err.h"
-
-extern LogFile dbglogfile;
 
 Tcputil::Tcputil(void) : Tcputil("localhost", DEFAULTPORT)
 {
@@ -68,9 +65,9 @@ Tcputil::Tcputil(const std::string &host, short port)
     // Chances are we don't have an entry in the /etc/services file.
     _service = getservbyport(htons(port), _proto->p_name);
     if (_service) {
-        dbglogfile <<  "Found service file entry for " << _service->s_name << 
std::endl;
+        BOOST_LOG(lg) <<  "Found service file entry for " << _service->s_name;
     } else {
-        dbglogfile << "Services file entry for port " << DEFAULTPORT << " was 
not found, using defaults" << std::endl;
+        BOOST_LOG(lg) << "Services file entry for port " << DEFAULTPORT << " 
was not found, using defaults";
     }
 #endif
 }
@@ -116,7 +113,7 @@ Tcputil::getAddrInfo(const std::string& hostname, 
std::uint16_t port)
     }
     while (addr->ai_next != 0) {
         std::string str;
-        dbglogfile << "The IP number for this connection is " << printIP(addr, 
str) << std::endl;
+        BOOST_LOG(lg) << "The IP number for this connection is " << 
printIP(addr, str);
         _addrinfo.push_back(addr);
         addr = addr->ai_next;
     }
@@ -168,9 +165,9 @@ Tcputil::lookupService(const std::string &name, const 
std::string &protocol)
     struct servent *serv = getservbyname(name.c_str(), protocol.c_str());
 
     if (serv) {
-        dbglogfile <<  "Found service file entry for " << name << std::endl;
+        BOOST_LOG(lg) <<  "Found service file entry for " << name;
     } else {
-        dbglogfile << "Services file entry " << name << " was not found!" << 
std::endl;
+        BOOST_LOG(lg) << "Services file entry " << name << " was not found!";
     }
 
     return serv;
diff --git a/lib/xml.cc b/lib/xml.cc
index f5b02dd..d222b46 100644
--- a/lib/xml.cc
+++ b/lib/xml.cc
@@ -35,8 +35,6 @@
 #include "xml.h"
 #include "log.h"
 
-extern LogFile dbglogfile;
-
 // XMLNode methods. An XMLNode holds all the info for an XML node,
 // including it's children and attributes.
 // XMLNode::XMLNode()
@@ -61,9 +59,9 @@ XML::extractNode(xmlNodePtr node)
     XMLNode *child;
     int len;
 
-    // dbglogfile << "\rCreated new element for " << (const char *)node->name 
<< " at " << element << std::endl;
+    // BOOST_LOG(lg) << "\rCreated new element for " << (const char 
*)node->name << " at " << element << std::endl;
 
-    dbglogfile << "extracting node " << node->name << std::endl;
+    BOOST_LOG(lg) << "extracting node " << node->name << std::endl;
 
     XMLNode *xml = new XMLNode;
     std::string name;
@@ -78,7 +76,7 @@ XML::extractNode(xmlNodePtr node)
             xml->attribAdd(name, value);
             attr = attr->next;
 #if 0
-            dbglogfile << "FIXME: attribute " << node->name
+            BOOST_LOG(lg) << "FIXME: attribute " << node->name
                        << " has property "
                        << name << " value is "
                        << value << std::endl;
@@ -103,7 +101,7 @@ XML::extractNode(xmlNodePtr node)
             //value = reinterpret_cast<const char *>(node->children->content);
             value = reinterpret_cast<const char *>(ptr);
 #if 1
-            dbglogfile << "\tChild node: " << name
+            BOOST_LOG(lg) << "\tChild node: " << name
                        << " has contents " << value << std::endl;
 #endif
             xml->valueSet(value.substr(0, value.find('\n')));
@@ -116,11 +114,11 @@ XML::extractNode(xmlNodePtr node)
 
     while (childnode != NULL) {
         if (childnode->type == XML_ELEMENT_NODE) {
-            dbglogfile << "\tfound node " << (const char *)childnode->name << 
std::endl;
+            BOOST_LOG(lg) << "\tfound node " << (const char *)childnode->name 
<< std::endl;
             XMLNode *child = extractNode(childnode);
             //if (child->_value.get_type() != as_value::UNDEFINED) {
 #if 1
-            dbglogfile << "\tPushing child Node " << child->nameGet()
+            BOOST_LOG(lg) << "\tPushing child Node " << child->nameGet()
                        << " value " << child->valueGet()
                        <<  " on element "
                        <<  xml->nameGet() << std::endl;
@@ -141,10 +139,10 @@ XML::parseMem(const std::string &xml_in)
     DEBUGLOG_REPORT_FUNCTION;
     bool          ret = true;
 
-    dbglogfile << "Parse XML from memory: " << xml_in.c_str() << std::endl;
+    BOOST_LOG(lg) << "Parse XML from memory: " << xml_in.c_str() << std::endl;
 
     if (xml_in.size() == 0) {
-        dbglogfile << "ERROR: XML data is empty!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: XML data is empty!" << std::endl;
         return false;
     }
 
@@ -152,7 +150,7 @@ XML::parseMem(const std::string &xml_in)
   
     _doc = xmlParseMemory(xml_in.c_str(), xml_in.size());
     if (_doc == 0) {
-        dbglogfile << "ERROR: Can't parse XML data!" << std::endl;
+        BOOST_LOG(lg) << "ERROR: Can't parse XML data!" << std::endl;
         return false;
     }
     _nodes = extractNode(xmlDocGetRootElement(_doc));
@@ -194,14 +192,14 @@ bool
 XML::parseFile(const std::string &filespec)
 {
     DEBUGLOG_REPORT_FUNCTION;
-    dbglogfile << "Load disk XML file: " << filespec << std::endl;
+    BOOST_LOG(lg) << "Load disk XML file: " << filespec << std::endl;
   
-    //dbglogfile << %s: mem is %d\n", __FUNCTION__, mem);
+    //BOOST_LOG(lg) << %s: mem is %d\n", __FUNCTION__, mem);
 
     xmlInitParser();
     _doc = xmlParseFile(filespec.c_str());
     if (_doc == 0) {
-        dbglogfile << "ERROR: Can't load XML file: " << filespec << std::endl;
+        BOOST_LOG(lg) << "ERROR: Can't load XML file: " << filespec << 
std::endl;
         return false;
     }
     //_nodes = extractNode(xmlDocGetRootElement(_doc));
diff --git a/lib/xml.h b/lib/xml.h
index 85a8930..8ae2d97 100644
--- a/lib/xml.h
+++ b/lib/xml.h
@@ -32,7 +32,6 @@
 #include <libxml/xmlreader.h>
 #include <libxml/xmlstring.h>
 #include "xml.h"
-#include "log.h"
 
 // This holds the data (name & value) for an XML node.
 class XMLNode
diff --git a/missing b/missing
index 64b5f90..625aeb1 100755
--- a/missing
+++ b/missing
@@ -1,11 +1,10 @@
 #! /bin/sh
-# Common stub for a few missing GNU programs while installing.
+# Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2004-09-07.08
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
-#   Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <address@hidden>, 1996.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Originally written by Fran,cois Pinard <address@hidden>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,9 +17,7 @@ scriptversion=2004-09-07.08
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -28,326 +25,191 @@ scriptversion=2004-09-07.08
 # the same distribution terms that you use for the rest of that program.
 
 if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
+  echo 1>&2 "Try '$0 --help' for more information"
   exit 1
 fi
 
-run=:
+case $1 in
 
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
-
-msg="missing on your system"
+  --is-lightweight)
+    # Used by our autoconf macros to check whether the available missing
+    # script is modern enough.
+    exit 0
+    ;;
 
-case "$1" in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  # Exit code 63 means version mismatch.  This often happens
-  # when the user try to use an ancient version of a tool on
-  # a file that requires a minimum version.  In this case we
-  # we should proceed has if the program had been absent, or
-  # if --run hadn't been passed.
-  if test $? = 63; then
-    run=:
-    msg="probably too old"
-  fi
-  ;;
+  --run)
+    # Back-compat with the calling convention used by older automake.
+    shift
+    ;;
 
   -h|--h|--he|--hel|--help)
     echo "\
 $0 [OPTION]... PROGRAM [ARGUMENT]...
 
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
+Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
+to PROGRAM being missing or too old.
 
 Options:
   -h, --help      display this help and exit
   -v, --version   output version information and exit
-  --run           try to run the given command, and emulate it if it fails
 
 Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
-  help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
-  makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
+  bison     yacc      flex         lex       help2man
+
+Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
+'g' are ignored when checking the name.
 
 Send bug reports to <address@hidden>."
-    exit 0
+    exit $?
     ;;
 
   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
     echo "missing $scriptversion (GNU Automake)"
-    exit 0
+    exit $?
     ;;
 
   -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
+    echo 1>&2 "$0: unknown '$1' option"
+    echo 1>&2 "Try '$0 --help' for more information"
     exit 1
     ;;
 
 esac
 
-# Now exit if we have it, but it failed.  Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).
-case "$1" in
-  lex|yacc)
-    # Not GNU programs, they don't have --version.
-    ;;
-
-  tar)
-    if test -n "$run"; then
-       echo 1>&2 "ERROR: \`tar' requires --run"
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       exit 1
-    fi
-    ;;
-
-  *)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       # Could not run --version or --help.  This is probably someone
-       # running `$TOOL --version' or `$TOOL --help' to check whether
-       # $TOOL exists and not knowing $TOOL uses missing.
-       exit 1
-    fi
-    ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
-  aclocal*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
-         any GNU archive site."
-    touch aclocal.m4
-    ;;
-
-  autoconf)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
-         archive site."
-    touch configure
-    ;;
-
-  autoheader)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
-         from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' 
${configure_ac}`
-    test -z "$files" && files="config.h"
-    touch_files=
-    for f in $files; do
-      case "$f" in
-      *:*) touch_files="$touch_files "`echo "$f" |
-                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
-         Grab them from any GNU archive site."
-    find . -type f -name Makefile.am -print |
-          sed 's/\.am$/.in/' |
-          while read f; do touch "$f"; done
-    ;;
-
-  autom4te)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
-    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
-    if test -f "$file"; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo "#! /bin/sh"
-       echo "# Created by GNU Automake missing as a replacement of"
-       echo "#  $ $@"
-       echo "exit 0"
-       chmod +x $file
-       exit 1
-    fi
-    ;;
-
-  bison|yacc)
-    echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
-         in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
-    rm -f y.tab.c y.tab.h
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-       case "$LASTARG" in
-       *.y)
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" y.tab.c
-           fi
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" y.tab.h
-           fi
-         ;;
-       esac
-    fi
-    if [ ! -f y.tab.h ]; then
-       echo >y.tab.h
-    fi
-    if [ ! -f y.tab.c ]; then
-       echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex|flex)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
-         in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
-    rm -f lex.yy.c
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-       case "$LASTARG" in
-       *.l)
-           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" lex.yy.c
-           fi
-         ;;
-       esac
-    fi
-    if [ ! -f lex.yy.c ]; then
-       echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-        you modified a dependency of a manual page.  You may need the
-        \`Help2man' package in order for those modifications to take
-        effect.  You can get \`Help2man' from any GNU archive site."
-
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
-    fi
-    if [ -f "$file" ]; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo ".ab help2man is required to generate this page"
-       exit 1
-    fi
-    ;;
-
-  makeinfo)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
-         indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '/address@hidden/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
-    fi
-    touch $file
-    ;;
-
-  tar)
-    shift
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar "$@" && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar "$@" && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-       case "$firstarg" in
-       *o*)
-           firstarg=`echo "$firstarg" | sed s/o//`
-           tar "$firstarg" "$@" && exit 0
-           ;;
-       esac
-       case "$firstarg" in
-       *h*)
-           firstarg=`echo "$firstarg" | sed s/h//`
-           tar "$firstarg" "$@" && exit 0
-           ;;
-       esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequisites for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
-    ;;
-esac
+# Run the given program, remember its exit status.
+"$@"; st=$?
+
+# If it succeeded, we are done.
+test $st -eq 0 && exit 0
+
+# Also exit now if we it failed (or wasn't found), and '--version' was
+# passed; such an option is passed most likely to detect whether the
+# program is present and works.
+case $2 in --version|--help) exit $st;; esac
+
+# Exit code 63 means version mismatch.  This often happens when the user
+# tries to use an ancient version of a tool on a file that requires a
+# minimum version.
+if test $st -eq 63; then
+  msg="probably too old"
+elif test $st -eq 127; then
+  # Program was missing.
+  msg="missing on your system"
+else
+  # Program was found and executed, but failed.  Give up.
+  exit $st
+fi
 
-exit 0
+perl_URL=https://www.perl.org/
+flex_URL=https://github.com/westes/flex
+gnu_software_URL=https://www.gnu.org/software
+
+program_details ()
+{
+  case $1 in
+    aclocal|automake)
+      echo "The '$1' program is part of the GNU Automake package:"
+      echo "<$gnu_software_URL/automake>"
+      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/autoconf>"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+    autoconf|autom4te|autoheader)
+      echo "The '$1' program is part of the GNU Autoconf package:"
+      echo "<$gnu_software_URL/autoconf/>"
+      echo "It also requires GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+  esac
+}
+
+give_advice ()
+{
+  # Normalize program name to check for.
+  normalized_program=`echo "$1" | sed '
+    s/^gnu-//; t
+    s/^gnu//; t
+    s/^g//; t'`
+
+  printf '%s\n' "'$1' is $msg."
+
+  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
+  case $normalized_program in
+    autoconf*)
+      echo "You should only need it if you modified 'configure.ac',"
+      echo "or m4 files included by it."
+      program_details 'autoconf'
+      ;;
+    autoheader*)
+      echo "You should only need it if you modified 'acconfig.h' or"
+      echo "$configure_deps."
+      program_details 'autoheader'
+      ;;
+    automake*)
+      echo "You should only need it if you modified 'Makefile.am' or"
+      echo "$configure_deps."
+      program_details 'automake'
+      ;;
+    aclocal*)
+      echo "You should only need it if you modified 'acinclude.m4' or"
+      echo "$configure_deps."
+      program_details 'aclocal'
+      ;;
+   autom4te*)
+      echo "You might have modified some maintainer files that require"
+      echo "the 'autom4te' program to be rebuilt."
+      program_details 'autom4te'
+      ;;
+    bison*|yacc*)
+      echo "You should only need it if you modified a '.y' file."
+      echo "You may want to install the GNU Bison package:"
+      echo "<$gnu_software_URL/bison/>"
+      ;;
+    lex*|flex*)
+      echo "You should only need it if you modified a '.l' file."
+      echo "You may want to install the Fast Lexical Analyzer package:"
+      echo "<$flex_URL>"
+      ;;
+    help2man*)
+      echo "You should only need it if you modified a dependency" \
+           "of a man page."
+      echo "You may want to install the GNU Help2man package:"
+      echo "<$gnu_software_URL/help2man/>"
+    ;;
+    makeinfo*)
+      echo "You should only need it if you modified a '.texi' file, or"
+      echo "any other file indirectly affecting the aspect of the manual."
+      echo "You might want to install the Texinfo package:"
+      echo "<$gnu_software_URL/texinfo/>"
+      echo "The spurious makeinfo call might also be the consequence of"
+      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
+      echo "want to install GNU make:"
+      echo "<$gnu_software_URL/make/>"
+      ;;
+    *)
+      echo "You might have modified some files without having the proper"
+      echo "tools for further handling them.  Check the 'README' file, it"
+      echo "often tells you about the needed prerequisites for installing"
+      echo "this package.  You may also peek at any GNU archive site, in"
+      echo "case some other package contains this missing '$1' program."
+      ;;
+  esac
+}
+
+give_advice "$1" | sed -e '1s/^/WARNING: /' \
+                       -e '2,$s/^/         /' >&2
+
+# Propagate the correct exit status (expected to be 127 for a program
+# not found, 63 for a program that failed due to version mismatch).
+exit $st
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index 092b4e0..177a93c 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -31,6 +31,7 @@ localedir = $(libdir)/locale
 gnulocaledir = $(datadir)/locale
 gettextsrcdir = $(datadir)/glib-2.0/gettext/po
 subdir = po
+datarootdir = @datarootdir@
 
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
diff --git a/powerguru.sql b/powerguru.sql
index 455edf9..97ec0eb 100644
--- a/powerguru.sql
+++ b/powerguru.sql
@@ -61,7 +61,8 @@ CREATE TABLE onewire (
   "timestamp" timestamp without time zone,
   temphigh float NOT NULL default '0',
   templow float NOT NULL default '0',
-  temperature float NOT NULL default '0'
+  temperature float NOT NULL default '0',
+  scale char(1) NOT NULL default 'F'
 );
 
 /*!40101 SET address@hidden */;
diff --git a/sim/fakeuart.cc b/sim/fakeuart.cc
index 33f05d5..6e766d5 100644
--- a/sim/fakeuart.cc
+++ b/sim/fakeuart.cc
@@ -20,7 +20,6 @@
 #include <unistd.h>
 
 #include "log.h"
-#include "err.h"
 #include "fakeuart.h"
 
 #include <sys/types.h>
@@ -44,7 +43,7 @@ FakeUart::FakeUart(void)
 
 FakeUart::~FakeUart(void)
 {
-    dbglogfile << "Closing fake uart " << name << std::endl;
+    BOOST_LOG(lg) << "Closing fake uart " << name << std::endl;
 
   // Don't try to close a device that isn't open
   if (state == OPEN) {
@@ -53,8 +52,8 @@ FakeUart::~FakeUart(void)
 }
 
 retcode_t
-//FakeUart::Open(string &filespec, ErrCond &err)
-FakeUart::Open(ErrCond &err)
+//FakeUart::Open(string &filespec)
+FakeUart::Open(void)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
@@ -66,28 +65,30 @@ FakeUart::Open(ErrCond &err)
     const char *numberpart = "0123456789abcdef";
 
     filespec = "/dev/ptmx";
-    dbglogfile << "Looking for a pty: " << filespec.c_str() << std::endl;
+    BOOST_LOG(lg) << "Looking for a pty...";
     if ((master = open(filespec.c_str(), O_RDWR | O_NONBLOCK)) < 0) {
         if (errno == ENOENT) {
             std::cerr << "ERROR: no more pty's available";
             return ERROR;
         }
     } else {
-        dbglogfile << "Opening pty master: " << filespec << std::endl; 
+        BOOST_LOG(lg) << "found pty master: " << filespec << std::endl; 
     }
     
     // Search for a free pty
     for(i=0; i<16 && master <= 0; i++) {
         for(j=0; j<16 && master <= 0; j++) {
-            filespec[8] = letterpart[i];
-            filespec[9] = numberpart[j];
-            dbglogfile << "Opening pty: " << filespec.c_str() << std::endl;
+            //filespec[8] = letterpart[i];
+            //filespec[9] = numberpart[j];
+            filespec += letterpart[i];
+            filespec += numberpart[j];
+            BOOST_LOG(lg) << "Opening pty: " << filespec << std::endl;
             if ((master = open(filespec.c_str(), O_RDWR | O_NONBLOCK)) < 0) {
                 if (errno == ENOENT) {
                     std::cerr << "ERROR: no more pty's available";
                     return ERROR;
                 } else {
-                    dbglogfile << "Opened pty: " << filespec << std::endl;
+                    BOOST_LOG(lg) << "Opened pty: " << filespec << std::endl;
                 }
             }
         } // for j loop
@@ -105,7 +106,7 @@ FakeUart::Open(ErrCond &err)
     //filespec[5] = 't';
     filespec = ptsname(master);
 
-    dbglogfile << "Opened " << ptsname(master) << " with file descriptor " << 
master << std::endl;
+    BOOST_LOG(lg) << "Opened " << ptsname(master) << " with file descriptor " 
<< master << std::endl;
 
     grantpt(master);
     unlockpt(master);
@@ -132,7 +133,7 @@ FakeUart::Open(ErrCond &err)
 }
 
 retcode_t
-FakeUart::Close(std::string &filespec, ErrCond &err)
+FakeUart::Close(const std::string &filespec)
 {
     DEBUGLOG_REPORT_FUNCTION;
 
@@ -145,38 +146,37 @@ FakeUart::Close(std::string &filespec, ErrCond &err)
 }
 
 int
-FakeUart::Read(unsigned char *buf, int nbytes, ErrCond &err)
+FakeUart::Read(unsigned char *buf, int nbytes)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     return read (_uartfd, buf, nbytes);
 }
 
-#if 0
 int
-FakeUart::Write(std::string &str, ErrCond &err)
+FakeUart::Write(const std::string &str)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
     if (!str.empty()) {
-        dbglogfile << "Writing " << str << " to uart FD: " << _uartfd << 
std::endl;
-        //write(4, str.c_str(), str.size());
+        //BOOST_LOG(lg) << "Writing data to uart FD: " << _uartfd << std::endl;
+        //BOOST_LOG(lg) << "Writing " << str << " to uart FD: " << _uartfd << 
std::endl;
+        write(4, str.c_str(), str.size());
         //write (_uartfd, str.c_str(), str.size());
     }
 }
 
+#if 0
 int
-FakeUart::Write(const unsigned char *buf, int nbytes, ErrCond &err)
+FakeUart::Write(const unsigned char *buf, int nbytes)
 {
-    DEBUGLOG_REPORT_FUNCTION;
+//    DEBUGLOG_REPORT_FUNCTION;
 
-    //write (_uartfd, buf, nbytes);
+    write (_uartfd, buf, nbytes);
 }
-#endif
 
-#if 0
 int
-FakeUart::GetChar(char *buf, ErrCond &err)
+FakeUart::GetChar(char *buf)
 {
     //  DEBUGLOG_REPORT_FUNCTION;
 
@@ -184,23 +184,24 @@ FakeUart::GetChar(char *buf, ErrCond &err)
   
     return (int)*buf;
 }
+#endif
 
-ostream &operator<<(ostream &os, FakeUart &l) {
+std::ostream &operator<<(std::ostream &os, FakeUart &l) {
     return os << l.GetName();
 }
 
 FakeUart&
 FakeUart::operator << (int x) {
 
-    dbglogfile << x;
+    BOOST_LOG(lg) << x;
 
     if (state == OPEN)
         write (_uartfd, (char *)&x, sizeof(int)); 
 }
 
 FakeUart& 
-FakeUart::operator << (std::string &s) {
-    dbglogfile << s;
+FakeUart::operator << (const std::string &s) {
+    BOOST_LOG(lg) << s;
   
     if (state == OPEN)
         *this << s.c_str();
@@ -208,17 +209,16 @@ FakeUart::operator << (std::string &s) {
 
 FakeUart& 
 FakeUart::operator << (const char *c) {
-    dbglogfile << c;
+    BOOST_LOG(lg) << c;
   
     if (state == OPEN) {
         write (_uartfd, c, strlen(c));
     }
 }
-#endif
 
 // Accessors
 inline void
-FakeUart::SetName (std::string &newname)
+FakeUart::SetName (const std::string &newname)
 {
     name = newname;
 }
diff --git a/sim/fakeuart.h b/sim/fakeuart.h
index 0177432..a069412 100644
--- a/sim/fakeuart.h
+++ b/sim/fakeuart.h
@@ -26,8 +26,6 @@
 #include <iostream>
 #include <fstream>
 
-#include "err.h"
-
 #define DEFAULT_FAKEUART "/dev/ptypc"
 
 class FakeUart {
@@ -35,26 +33,13 @@ public:
   enum state_e {IDLE, OPEN, INPROGRESS, CLOSED};
   FakeUart(void);
   ~FakeUart(void);
-  retcode_t Open(ErrCond &err);
-  retcode_t Open(std::string &filespec, ErrCond &err);
-  retcode_t Close(std::string &filespec, ErrCond &err);
-
-  int Read(unsigned char *, int, ErrCond &);
-  int Write(const unsigned char *, int, ErrCond &) 
-  {
-
-  }
-  
-  int Write(std::string &str, ErrCond &) {
-    DEBUGLOG_REPORT_FUNCTION;
-    
-    if (!str.empty()) {
-      //dbglogfile << "Writing " << str << " to uart FD: " << _uartfd << 
std::endl;
-      //write(4, str.c_str(), str.size());
-      //write (_uartfd, str.c_str(), str.size());
-      write(4, "Hello World!\r\n", 12); 
-    }
-  }
+  retcode_t Open(void);
+  retcode_t Open(const std::string &filespec);
+  retcode_t Close(const std::string &filespec);
+
+  int Read(unsigned char *, int);
+  //int Write(const unsigned char *, int);
+  int Write(const std::string &str);
   void SendEOL(void);
 
    // get a byte from the console
@@ -67,12 +52,12 @@ public:
   int Putc (int x) { return Putc (x, uartStream); }
   int Putc (int x, FILE * y) { return putc(x, y); }
 
-  FakeUart& operator << (int);
-  FakeUart& operator << (const char *);
-  FakeUart& operator << (std::string);
+  FakeUart &operator << (int);
+  FakeUart &operator << (const char *);
+  FakeUart &operator << (const std::string &);
   //  ostream&  operator << (ostream & (&)(ostream &));
 
-  void SetName (std::string &name);
+  void SetName (const std::string &name);
   std::string &GetName (void) { return name; }
 
 
diff --git a/sim/osim.cc b/sim/osim.cc
index 1ff96b4..c909565 100644
--- a/sim/osim.cc
+++ b/sim/osim.cc
@@ -39,16 +39,14 @@ extern char *optarg;
 
 // local header files
 #include "log.h"
-#include "err.h"
 #include "outbackpower.h"
 #include "console.h"
 #include "fakeuart.h"
 #include "rc.h"
 
 using namespace rcinit;
-using namespace pdev;
 
-static void usage (const char *);
+static void usage (const std::string &);
 extern LogFile dbglogfile;
  
 retcode_t sim_mx(const std::string &filespec);
@@ -59,7 +57,6 @@ main(int argc, char *argv[])
 {
     int c, i, ch, ret;
     std::string device;
-    ErrCond Err;
     outback_type_t otype;
     
     if (argc == 1) {
@@ -89,7 +86,7 @@ main(int argc, char *argv[])
       case 'v':
         // verbosity++;
        dbglogfile.set_verbosity();
-       dbglogfile << "Verbose output turned on" << std::endl;
+       BOOST_LOG(lg) << "Verbose output turned on" << std::endl;
        break;
         
       case 'd':
@@ -116,11 +113,11 @@ main(int argc, char *argv[])
 
     // Say which device we're simulating
     if (otype == OUTBACK_MX) {
-      dbglogfile << "Simulating a Outback MX60 charge controller" << std::endl;
+      BOOST_LOG(lg) << "Simulating a Outback MX60 charge controller" << 
std::endl;
       sim_mx(device);
     }
     if (otype == OUTBACK_FX) {
-      dbglogfile << "Simulating a Outback FX Series Inverter" << std::endl;
+      BOOST_LOG(lg) << "Simulating a Outback FX Series Inverter" << std::endl;
       sim_fx(device);
     }
 
@@ -128,7 +125,7 @@ main(int argc, char *argv[])
 }
 
 static void
-usage (const char *prog)
+usage (const std::string &prog)
 {
     std::cerr <<"This program implements a command line interface" << 
std::endl; 
     std::cerr << "for an Outback Power Systems Device" << std::endl;
@@ -147,7 +144,6 @@ sim_mx(const std::string &device)
     //struct stat stats;
     std::string datafile;
     std::string home;
-    ErrCond err;
     std::string line, newline;
     std::ifstream in;
     FakeUart fu;
@@ -156,20 +152,20 @@ sim_mx(const std::string &device)
     }
     
     // See if it exists in the right place
-    fu.Open(err);
+    fu.Open();
     
     // Check the users home directory for the data file
     datafile = std::getenv("HOME");
     datafile += "/.powerguru/mx60.data";
     
-    //dbglogfile << "Seeing if the TTY "<< device << " exists." << std::endl;
+    //BOOST_LOG(lg) << "Seeing if the TTY "<< device << " exists." << 
std::endl;
     //if (stat(datafile.c_str(), &stats) == 0) {
     in.open(datafile);
     if (!in) {
-        dbglogfile << "ERROR: Couldn't open datafile: " << datafile << 
std::endl;
+        BOOST_LOG(lg) << "ERROR: Couldn't open datafile: " << datafile << 
std::endl;
         return ERROR;
     } else {
-        dbglogfile << "Opened datafile: " << datafile << std::endl;
+        BOOST_LOG(lg) << "Opened datafile: " << datafile << std::endl;
     }
         
     // Read in each line and send it
@@ -178,9 +174,7 @@ sim_mx(const std::string &device)
         newline = line;
         newline += "\r\n";
         std::cout << newline;
-        write(4, newline.c_str(), newline.size());
-        //fu.Write(newline, err);
-        //fu.Write((const unsigned char *)newline.c_str(), newline.size(), 
err);
+        fu.Write(newline);
         // All outback products send their data at 1 second intervals
         sleep(1);
     }
diff --git a/snmp/Makefile.am b/snmp/Makefile.am
index fb39bfb..b5f314e 100644
--- a/snmp/Makefile.am
+++ b/snmp/Makefile.am
@@ -31,7 +31,7 @@ libpgsnmp_la_SOURCES = \
 #              ifTable_data_access.c \
 #              ifTable_data_set.c
 
-AM_CPPFLAGS = -I$(srcdir) -I.. $(SNMP_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir) -I.. $(SNMP_CPPFLAGS)
 libpgsnmp_la_LIBDADD =  $(SNMP_LIBS)
 
 generate-templates:
diff --git a/snmp/POWERGURU-MIB.txt b/snmp/POWERGURU-MIB.txt
index ba88530..56bfe01 100644
--- a/snmp/POWERGURU-MIB.txt
+++ b/snmp/POWERGURU-MIB.txt
@@ -139,7 +139,7 @@ powerGuruErrorMode OBJECT-TYPE
     STATUS     current
     DESCRIPTION
        "This is the current Error mode. A table lookup must be
-        done to get the vaue. This is currently unimplemented on the
+        done to get the value. This is currently unimplemented on the
         MX series."
     ::= { powerguru 9 }
 
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index cbbe068..7d564b4 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -31,6 +31,6 @@ RUNTEST = `if test -x $(top_srcdir)/../dejagnu/runtest; then \
            else \
               echo runtest; \
            fi`
- 
+
 CLEANFILES = *.log *.sum site.bak
 
diff --git a/testsuite/libtests/childtcpip.cc b/testsuite/libtests/childtcpip.cc
index 534c969..3a23b3b 100644
--- a/testsuite/libtests/childtcpip.cc
+++ b/testsuite/libtests/childtcpip.cc
@@ -83,16 +83,17 @@ main(int argc, char *argv[])
     tcpip.readNet(data);
     if (data.size() > 0) {
         std::cout << "Child read " << data.size() <<" bytes from parent:" << 
std::endl;
+        runtest.pass("child readNet");
+    } else {
+        runtest.fail("child readNet()");
     }  
-
-    sleep(2);
 }
 
 static void
 usage (void)
 {
-    std::cerr << "This program tests the Global memory system." << std::endl;
-    std::cerr << "Usage: tglobal [h] filename" << std::endl;
+    std::cerr << "This program tests the tcpip subsystem." << std::endl;
+    std::cerr << "Usage: childtcpip [h]" << std::endl;
     std::cerr << "-h\tHelp" << std::endl;
     std::cerr << "-d\tDump parsed data" << std::endl;
     exit (-1);
diff --git a/testsuite/libtests/tcpip-test.cc b/testsuite/libtests/tcpip-test.cc
index 7d39362..9444ea0 100644
--- a/testsuite/libtests/tcpip-test.cc
+++ b/testsuite/libtests/tcpip-test.cc
@@ -21,7 +21,6 @@
 # include "config.h"
 #endif
 
-
 #include <stdarg.h>
 #include <signal.h>
 #include <netinet/in.h>
@@ -122,14 +121,13 @@ public:
         // Read data from the child process
         std::vector<unsigned char> data;
         readNet(data);
-
         if (data.size() > 0) {
-            runtest.pass("Established netork connection");
+            runtest.pass("Established network connection from client");
         } else {
-            runtest.fail("Established netork connection");
+            runtest.fail("Established network connection from client");
         }
 
-        sleep(1);
+        writeNet("done");
         closeNet();
     };
 
diff --git a/testsuite/libtests/tcputil-test.cc 
b/testsuite/libtests/tcputil-test.cc
index c198be3..34476de 100644
--- a/testsuite/libtests/tcputil-test.cc
+++ b/testsuite/libtests/tcputil-test.cc
@@ -52,7 +52,7 @@ const short DEFAULTPORT  = 7654;
 
 class Test : public Tcputil
 {
-public:    
+public:
     Test(void) {
         // Get some system information needed to test the classes.
         std::memset(_thost, 0, MAXHOSTNAMELEN);
@@ -81,7 +81,7 @@ public:
         }
 
         // Check the defaults
-        if (_hostname == _thost) {
+        if (_hostname != _thost && _hostname == "localhost") {
             runtest.pass ("Hostname is correct");
         } else {
             runtest.fail ("Hostname is not correct");
@@ -103,6 +103,28 @@ public:
         } else {
             runtest.fail ("Tcputil::lookupService(ftp)");
         }
+
+        struct addrinfo *addr;
+        if (addr = getAddrInfo()) {
+            runtest.pass ("Tcputil::getAddrInfo()");
+        } else {
+            runtest.fail ("Tcputil::getAddrInfo()");
+        }
+
+        std::string str;
+        if (printIP(addr, str) == "127.0.0.1") {
+            runtest.pass ("Tcputil::printIP()");
+        } else {
+            runtest.fail ("Tcputil::printIP()");
+        }
+
+        if (addr = getAddrInfo("gnu.org")) {
+            runtest.pass ("Tcputil::getAddrInfo(gnu.org)");
+        } else {
+            runtest.fail ("Tcputil::getAddrInfo(gnu.org)");
+        }
+        
+        dump();
     };
     
     ~Test(void) {

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=146485a0d232a412e904c26e48aa287909e4e3f8


commit 146485a0d232a412e904c26e48aa287909e4e3f8
Author: Rob Savoye <address@hidden>
Date:   Fri Dec 28 19:45:06 2018 -0700

    Move serial files

diff --git a/devices/Makefile.am b/devices/Makefile.am
index a188a70..3fcdaa7 100644
--- a/devices/Makefile.am
+++ b/devices/Makefile.am
@@ -28,7 +28,7 @@ noinst_LTLIBRARIES = libpdev.la
 address@hidden@
 
 # These headers get installed
-# include_HEADERS = log.h err.h proc.h serial.h xantrex.h outback.h
+# include_HEADERS = log.h err.h proc.h serial.h xantrex.h outback.h serial.h
 
 libpdev_la_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib -I..
 libpdev_la_LIBDADD = -lboost_filesystem
@@ -41,6 +41,10 @@ if BUILD_OUTBACK
 libpdev_la_SOURCES += outbackpower.cc outbackpower.h
 endif
 
+if BUILD_SERIAL
+SERIAL_FILES = serial.cc serial.h
+endif
+
 if BUILD_SNMP
 SNMP_FILES = snmp.cc snmp.h
 libpdev_la_CPPFLAGS += -I$(top_srcdir)/snmp
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 91279e4..766165a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,5 +1,6 @@
 # 
-# Copyright (C) 2005, 2006-2018.
+# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+#               2014, 2015, 2016, 2017, 2018, 2019
 #      Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -35,19 +36,17 @@ libpguru_la_CPPFLAGS =      -I$(top_srcdir)/devices
 libpguru_la_LIBDADD =
 
 #      err.cc err.h
+#      log.cc log.h
 libpguru_la_SOURCES = \
        proc.cc proc.h \
-       log.cc log.h \
        rc.cc rc.h \
-       serial.cc serial.h \
        console.cc console.h \
-       menuitem.cc menuitem.h \
        database.h \
        tcputil.cc tcputil.h \
        tcpip.cc tcpip.h
 
 if BUILD_OUTBACK
-libpguru_la_SOURCES += msgs.cc msgs.h
+libpguru_la_SOURCES += msgs.cc msgs.h menuitem.cc menuitem.h
 endif
 
 if BUILD_LIBXML

-----------------------------------------------------------------------

Summary of changes:
 .gitmodules                        |   3 -
 README                             |  54 ++--
 client/Makefile.am                 |   8 +-
 client/cmd.cc                      |   8 +-
 client/threads.cc                  |   6 +-
 configure.ac                       |  11 +-
 cross.spec                         |   7 +-
 daemon/Makefile.am                 |   8 +-
 daemon/main.cc                     |  22 +-
 daemon/threads.cc                  |  48 +--
 depcomp                            | 635 ++++++++++++++++++++++++++-----------
 devices/Makefile.am                |   6 +-
 devices/onewire.cc                 |  11 +-
 devices/onewire.h                  |   2 -
 devices/outbackpower.cc            | 170 +++++-----
 devices/ownet.cc                   |  28 +-
 devices/ownet.h                    |   2 -
 {lib => devices}/serial.cc         |  37 ++-
 {lib => devices}/serial.h          |   3 -
 devices/xanbus.cc                  | 136 ++++----
 devices/xantrex-trace.cc           | 136 ++++----
 doc/C/Makefile.am                  |   7 +-
 doc/C/powerguru.xml                | 396 ++++-------------------
 lib/Makefile.am                    |  10 +-
 lib/commands.cc                    |  40 ++-
 lib/commands.h                     |   3 +-
 lib/console.cc                     |   2 +-
 lib/log.cc                         | 633 ++----------------------------------
 lib/log.h                          | 143 +++------
 lib/mariadb.cc                     |  26 +-
 lib/menuitem.cc                    |  38 +--
 lib/msgs.cc                        | 168 +++++-----
 lib/postgresql.cc                  |  17 +-
 lib/rc.cc                          |  37 ++-
 lib/rc.h                           |   4 +-
 lib/sharedlib.cc                   |  22 +-
 lib/tcpip.cc                       | 172 +++++-----
 lib/tcpip.h                        |   5 +-
 lib/tcputil.cc                     |  13 +-
 lib/xml.cc                         |  26 +-
 lib/xml.h                          |   1 -
 missing                            | 452 +++++++++-----------------
 po/Makefile.in.in                  |   1 +
 powerguru.sql                      |   3 +-
 sim/fakeuart.cc                    |  64 ++--
 sim/fakeuart.h                     |  37 +--
 sim/osim.cc                        |  26 +-
 snmp/Makefile.am                   |   2 +-
 snmp/POWERGURU-MIB.txt             |   2 +-
 testsuite/Makefile.am              |   2 +-
 testsuite/libtests/childtcpip.cc   |   9 +-
 testsuite/libtests/tcpip-test.cc   |   8 +-
 testsuite/libtests/tcputil-test.cc |  26 +-
 53 files changed, 1491 insertions(+), 2245 deletions(-)
 delete mode 100644 .gitmodules
 rename {lib => devices}/serial.cc (91%)
 rename {lib => devices}/serial.h (98%)


hooks/post-receive
-- 
powerguru



reply via email to

[Prev in Thread] Current Thread [Next in Thread]