got rid of all uses of strerror

This required some minor refactoring of other things and there were some
other small cleanups I noticed along the way.
diff --git a/aos/linux_code/starter/netconsole.cc b/aos/linux_code/starter/netconsole.cc
index f624673..4d32afe 100644
--- a/aos/linux_code/starter/netconsole.cc
+++ b/aos/linux_code/starter/netconsole.cc
@@ -92,9 +92,8 @@
       }
       if (read_bytes == -1) {
         if (errno != EINTR) {
-          LOG(FATAL, "read(%d, %p, %zd) failed with %d: %s\n",
-              to_copy->input, buffer + position, position - sizeof(buffer),
-              errno, strerror(errno));
+          PLOG(FATAL, "read(%d, %p, %zd) failed",
+               to_copy->input, buffer + position, position - sizeof(buffer));
         }
       } else if (read_bytes == 0 && to_copy->interface_address == NULL) {
         // read(2) says that this means EOF
@@ -111,8 +110,8 @@
       ssize_t sent_bytes = write(to_copy->output, buffer, position);
       if (sent_bytes == -1) {
         if (errno != EINTR) {
-          LOG(FATAL, "write(%d, %p, %zd) failed with %d: %s\n",
-              to_copy->output, buffer, position, errno, strerror(errno));
+          PLOG(FATAL, "write(%d, %p, %zd) failed",
+               to_copy->output, buffer, position);
         }
       } else if (sent_bytes != 0) {
         if (sent_bytes == position) {
@@ -129,6 +128,7 @@
 int NetconsoleMain(int argc, char **argv) {
   WriteCoreDumps();
   logging::Init();
+  logging::AddImplementation(new logging::StreamLogImplementation(stdout));
 
   int input, output;
   if (argc > 1) {
@@ -136,12 +136,9 @@
     if (output == -1) {
       if (errno == EACCES || errno == ELOOP || errno == ENOSPC ||
           errno == ENOTDIR || errno == EROFS || errno == ETXTBSY) {
-        fprintf(stderr, "Opening output file '%s' failed because of %s.\n",
-                argv[1], strerror(errno));
-        exit(EXIT_FAILURE);
+        PLOG(FATAL, "opening output file '%s' failed", argv[1]);
       }
-      LOG(FATAL, "open('%s', stuff, 0644) failed with %d: %s\n", argv[1],
-          errno, strerror(errno));
+      PLOG(FATAL, "open('%s', stuff, 0644) failed", argv[1]);
     }
     fprintf(stderr, "Writing output to '%s'.\n", argv[1]);
     input = -1;
@@ -157,20 +154,16 @@
 
   int from_crio = socket(AF_INET, SOCK_DGRAM, 0);
   if (from_crio == -1) {
-    LOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed with %d: %s\n",
-        errno, strerror(errno));
+    PLOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed");
   }
   if (setsockopt(from_crio, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
-    LOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed with %d: %s\n",
-        on, from_crio, errno, strerror(errno));
+    PLOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed", on, from_crio);
   }
   if (setsockopt(from_crio, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) == -1) {
-    LOG(FATAL, "SOL_SOCKET::SO_BROADCAST=%d(%d) failed with %d: %s\n",
-        on, from_crio, errno, strerror(errno));
+    PLOG(FATAL, "SOL_SOCKET::SO_BROADCAST=%d(%d) failed", on, from_crio);
   }
   if (setsockopt(from_crio, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on)) == -1) {
-    LOG(FATAL, "IPROTO_IP::IP_PKTINFO=%d(%d) failed with %d: %s\n",
-        on, from_crio, errno, strerror(errno));
+    PLOG(FATAL, "IPROTO_IP::IP_PKTINFO=%d(%d) failed", on, from_crio);
   }
   union {
     struct sockaddr_in in;
@@ -188,8 +181,8 @@
                               ::aos::NetworkAddress::kCRIO);
 
   if (bind(from_crio, &address.addr, sizeof(address)) == -1) {
-    LOG(FATAL, "bind(%d, %p, %zu) failed with %d: %s\n",
-        from_crio, &address.addr, sizeof(address), errno, strerror(errno));
+    PLOG(FATAL, "bind(%d, %p, %zu) failed",
+         from_crio, &address.addr, sizeof(address));
   }
 
   pthread_t input_thread, output_thread;
@@ -202,36 +195,33 @@
   if (input != -1) {
     int to_crio = socket(AF_INET, SOCK_DGRAM, 0);
     if (to_crio == -1) {
-      LOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed with %d: %s\n",
-          errno, strerror(errno));
+      PLOG(FATAL, "socket(AF_INET, SOCK_DGRAM, 0) failed");
     }
     if (setsockopt(to_crio, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
-      LOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed with %d: %s\n",
-          on, to_crio, errno, strerror(errno));
+      PLOG(FATAL, "SOL_SOCKET::SO_REUSEADDR=%d(%d) failed", on, to_crio);
     }
     address.in.sin_port = hton<uint16_t>(6668);
     if (connect(to_crio, &address.addr, sizeof(address)) == -1) {
-      LOG(FATAL, "connect(%d, %p, %zu) failed with %d: %s\n",
-          to_crio, &address.addr, sizeof(address), errno, strerror(errno));
+      PLOG(FATAL, "connect(%d, %p, %zu) failed",
+           to_crio, &address.addr, sizeof(address));
     }
     FDsToCopy input_fds{input, to_crio, nullptr, nullptr};
     if (pthread_create(&input_thread, NULL, FDCopyThread, &input_fds) == -1) {
-      LOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed with %d: %s\n",
-          &input_thread, FDCopyThread, &input_fds, errno, strerror(errno));
+      PLOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed",
+           &input_thread, FDCopyThread, &input_fds);
     }
   }
 
   address.in.sin_addr = ::aos::configuration::GetOwnIPAddress();
   FDsToCopy output_fds{from_crio, output, &address.in, &crio_address.in};
   if (pthread_create(&output_thread, NULL, FDCopyThread, &output_fds) == -1) {
-    LOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed with %d: %s\n",
-        &output_thread, FDCopyThread, &output_fds, errno, strerror(errno));
+    PLOG(FATAL, "pthread_create(%p, NULL, %p, %p) failed",
+         &output_thread, FDCopyThread, &output_fds);
   }
 
   // input_thread will finish when stdin gets an EOF
   if (pthread_join((input == -1) ? output_thread : input_thread, NULL) == -1) {
-    LOG(FATAL, "pthread_join(a_thread, NULL) failed with %d: %s\n",
-        errno, strerror(errno));
+    PLOG(FATAL, "pthread_join(a_thread, NULL) failed");
   }
   exit(EXIT_SUCCESS);
 }
diff --git a/aos/linux_code/starter/starter.cc b/aos/linux_code/starter/starter.cc
index 114148f..800acd9 100644
--- a/aos/linux_code/starter/starter.cc
+++ b/aos/linux_code/starter/starter.cc
@@ -112,8 +112,7 @@
     assert(watch_to_remove_ == -1);
 
     if (inotify_rm_watch(notify_fd, watch_) == -1) {
-      LOG(WARNING, "inotify_rm_watch(%d, %d) failed with %d: %s\n",
-          notify_fd, watch_, errno, strerror(errno));
+      PLOG(WARNING, "inotify_rm_watch(%d, %d) failed", notify_fd, watch_);
     }
     watch_to_remove_ = watch_;
     watch_ = -1;
@@ -159,10 +158,9 @@
                                                      IN_DELETE_SELF |
                                                      IN_MOVE_SELF));
     if (watch_ == -1) {
-      LOG(FATAL, "inotify_add_watch(%d, %s,"
-          " %s ? IN_CREATE : (IN_ATTRIB | IN_MODIFY)) failed with %d: %s\n",
-          notify_fd, filename_.c_str(), create_ ? "true" : "false",
-          errno, strerror(errno));
+      PLOG(FATAL, "inotify_add_watch(%d, %s,"
+                  " %s ? IN_CREATE : (IN_ATTRIB | IN_MODIFY)) failed",
+           notify_fd, filename_.c_str(), create_ ? "true" : "false");
     }
     watchers[watch_] = this;
     LOG(DEBUG, "watch for %s is %d\n", filename_.c_str(), watch_);
@@ -174,8 +172,7 @@
     unsigned int to_read;
     // Use FIONREAD to figure out how many bytes there are to read.
     if (ioctl(notify_fd, FIONREAD, &to_read) < 0) {
-      LOG(FATAL, "FIONREAD(%d, %p) failed with %d: %s\n",
-          notify_fd, &to_read, errno, strerror(errno));
+      PLOG(FATAL, "FIONREAD(%d, %p) failed", notify_fd, &to_read);
     }
     inotify_event *notifyevt = static_cast<inotify_event *>(malloc(to_read));
     const char *end = reinterpret_cast<char *>(notifyevt) + to_read;
@@ -183,8 +180,7 @@
 
     ssize_t ret = read(notify_fd, notifyevt, to_read);
     if (ret < 0) {
-      LOG(FATAL, "read(%d, %p, %u) failed with %d: %s\n",
-          notify_fd, notifyevt, to_read, errno, strerror(errno));
+      PLOG(FATAL, "read(%d, %p, %u) failed", notify_fd, notifyevt, to_read);
     }
     if (static_cast<size_t>(ret) != to_read) {
       LOG(ERROR, "read(%d, %p, %u) returned %zd instead of %u\n",
@@ -277,8 +273,7 @@
   errno = 0;
   FILE *pipe = popen(command.c_str(), "r");
   if (pipe == NULL) {
-    LOG(FATAL, "popen(\"%s\", \"r\") failed with %d: %s\n",
-        command.c_str(), errno, strerror(errno));
+    PLOG(FATAL, "popen(\"%s\", \"r\") failed", command.c_str());
   }
 
   // result_size is how many bytes result is currently allocated to.
@@ -290,8 +285,7 @@
       result_size *= 2;
       void *new_result = realloc(result.get(), result_size);
       if (new_result == NULL) {
-        LOG(FATAL, "realloc(%p, %zd) failed because of %d: %s\n",
-            result.get(), result_size, errno, strerror(errno));
+        PLOG(FATAL, "realloc(%p, %zd) failed", result.get(), result_size);
       } else {
         result.release();
         result = unique_c_ptr<char>(static_cast<char *>(new_result));
@@ -303,8 +297,8 @@
     // because of an error.
     if (ret < result_size - read) {
       if (ferror(pipe)) {
-        LOG(FATAL, "couldn't finish reading output of \"%s\"\n",
-            command.c_str());
+        PLOG(FATAL, "couldn't finish reading output of \"%s\"\n",
+             command.c_str());
       }
     }
     read += ret;
@@ -322,8 +316,7 @@
 
   int child_status = pclose(pipe);
   if (child_status == -1) {
-    LOG(FATAL, "pclose(%p) failed with %d: %s\n", pipe,
-        errno, strerror(errno));
+    PLOG(FATAL, "pclose(%p) failed", pipe);
   }
 
   if (child_status != 0) {
@@ -457,8 +450,8 @@
     if (stat_at_start_valid_) {
       struct stat current_stat;
       if (stat(original_binary_.c_str(), &current_stat) == -1) {
-        LOG(FATAL, "stat(%s, %p) failed with %d: %s\n",
-            original_binary_.c_str(), &current_stat, errno, strerror(errno));
+        PLOG(FATAL, "stat(%s, %p) failed",
+             original_binary_.c_str(), &current_stat);
       }
       if (current_stat.st_mtime == stat_at_start_.st_mtime) {
         LOG(DEBUG, "ignoring trigger for %s because mtime didn't change\n",
@@ -474,8 +467,7 @@
     if (pid_ != -1) {
       LOG(DEBUG, "sending SIGTERM to child %d to restart it\n", pid_);
       if (kill(pid_, SIGTERM) == -1) {
-        LOG(WARNING, "kill(%d, SIGTERM) failed with %d: %s\n",
-            pid_, errno, strerror(errno));
+        PLOG(WARNING, "kill(%d, SIGTERM) failed", pid_);
       }
       CheckDiedStatus *status = new CheckDiedStatus();
       status->self = this;
@@ -497,8 +489,7 @@
     if (pid_ == old_pid) {
       LOG(WARNING, "child %d refused to die\n", old_pid);
       if (kill(old_pid, SIGKILL) == -1) {
-        LOG(WARNING, "kill(%d, SIGKILL) failed with %d: %s\n",
-            old_pid, errno, strerror(errno));
+        PLOG(WARNING, "kill(%d, SIGKILL) failed", old_pid);
       }
     }
   }
@@ -513,8 +504,7 @@
       LOG(WARNING, "calling Start() but already have child %d running\n",
           pid_);
       if (kill(pid_, SIGKILL) == -1) {
-        LOG(WARNING, "kill(%d, SIGKILL) failed with %d: %s\n",
-            pid_, errno, strerror(errno));
+        PLOG(WARNING, "kill(%d, SIGKILL) failed", pid_);
         return;
       }
       pid_ = -1;
@@ -523,17 +513,16 @@
     // Remove the name that we run from (ie from a previous execution) and then
     // hard link the real filename to it.
     if (unlink(binary_.c_str()) != 0 && errno != ENOENT) {
-      LOG(FATAL, "removing %s failed because of %d: %s\n",
-          binary_.c_str(), errno, strerror(errno));
+      PLOG(FATAL, "removing %s failed", binary_.c_str());
     }
     if (link(original_binary_.c_str(), binary_.c_str()) != 0) {
-      LOG(FATAL, "link('%s', '%s') failed because of %d: %s\n",
-          original_binary_.c_str(), binary_.c_str(), errno, strerror(errno));
+      PLOG(FATAL, "link('%s', '%s') failed",
+           original_binary_.c_str(), binary_.c_str());
     }
 
     if (stat(original_binary_.c_str(), &stat_at_start_) == -1) {
-      LOG(FATAL, "stat(%s, %p) failed with %d: %s\n",
-          original_binary_.c_str(), &stat_at_start_, errno, strerror(errno));
+      PLOG(FATAL, "stat(%s, %p) failed",
+           original_binary_.c_str(), &stat_at_start_);
     }
     stat_at_start_valid_ = true;
 
@@ -547,13 +536,11 @@
       // The const_cast is safe because no code that might care if it gets
       // modified can run afterwards.
       execv(binary_.c_str(), const_cast<char **>(argv));
-      LOG(FATAL, "execv(%s, %p) failed with %d: %s\n",
-          binary_.c_str(), argv, errno, strerror(errno));
+      PLOG(FATAL, "execv(%s, %p) failed", binary_.c_str(), argv);
       _exit(EXIT_FAILURE);
     }
     if (pid_ == -1) {
-      LOG(FATAL, "forking to run \"%s\" failed with %d: %s\n",
-          binary_.c_str(), errno, strerror(errno));
+      PLOG(FATAL, "forking to run \"%s\" failed", binary_.c_str());
     }
     LOG(DEBUG, "started \"%s\" successfully\n", binary_.c_str());
   }
@@ -657,7 +644,7 @@
     siginfo_t infop;
     infop.si_pid = 0;
     if (waitid(P_ALL, 0, &infop, WEXITED | WSTOPPED | WNOHANG) != 0) {
-      LOG(WARNING, "waitid failed with %d: %s", errno, strerror(errno));
+      PLOG(WARNING, "waitid failed");
       continue;
     }
     // If there are no more child process deaths to process.
@@ -720,7 +707,7 @@
   // bring up shm is ok
 
   if (setpgid(0 /*self*/, 0 /*make PGID the same as PID*/) != 0) {
-    LOG(FATAL, "setpgid(0, 0) failed with %d: %s\n", errno, strerror(errno));
+    PLOG(FATAL, "setpgid(0, 0) failed");
   }
 
   // Make sure that we kill all children when we exit.
@@ -745,7 +732,7 @@
   core_touch_file += std::to_string(static_cast<intmax_t>(getpid()));
   core_touch_file += ".core_touch_file";
   if (system(("touch '" + core_touch_file + "'").c_str()) != 0) {
-    LOG(FATAL, "running `touch '%s'` failed\n", core_touch_file.c_str());
+    PLOG(FATAL, "running `touch '%s'` failed\n", core_touch_file.c_str());
   }
   FileWatch core_touch_file_watch(core_touch_file, Run, NULL);
   core = unique_ptr<Child>(
@@ -753,12 +740,11 @@
 
   FILE *pid_file = fopen("/tmp/starter.pid", "w");
   if (pid_file == NULL) {
-    LOG(FATAL, "fopen(\"/tmp/starter.pid\", \"w\") failed with %d: %s\n",
-        errno, strerror(errno));
+    PLOG(FATAL, "fopen(\"/tmp/starter.pid\", \"w\") failed");
   } else {
     if (fprintf(pid_file, "%d", core->pid()) == -1) {
-      LOG(WARNING, "fprintf(%p, \"%%d\", %d) failed with %d: %s\n",
-          pid_file, core->pid(), errno, strerror(errno));
+      PLOG(WARNING, "fprintf(%p, \"%%d\", %d) failed",
+           pid_file, core->pid());
     }
     fclose(pid_file);
   }